aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/linden/indra/llcommon/lllog.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'linden/indra/llcommon/lllog.cpp')
-rw-r--r--linden/indra/llcommon/lllog.cpp115
1 files changed, 115 insertions, 0 deletions
diff --git a/linden/indra/llcommon/lllog.cpp b/linden/indra/llcommon/lllog.cpp
new file mode 100644
index 0000000..147b2d3
--- /dev/null
+++ b/linden/indra/llcommon/lllog.cpp
@@ -0,0 +1,115 @@
1/**
2 * @file lllog.cpp
3 * @author Don
4 * @date 2007-11-27
5 * @brief Class to log messages to syslog for streambase to process.
6 *
7 * $LicenseInfo:firstyear=2007&license=viewergpl$
8 *
9 * Copyright (c) 2007-2008, Linden Research, Inc.
10 *
11 * Second Life Viewer Source Code
12 * The source code in this file ("Source Code") is provided by Linden Lab
13 * to you under the terms of the GNU General Public License, version 2.0
14 * ("GPL"), unless you have obtained a separate licensing agreement
15 * ("Other License"), formally executed by you and Linden Lab. Terms of
16 * the GPL can be found in doc/GPL-license.txt in this distribution, or
17 * online at http://secondlifegrid.net/programs/open_source/licensing/gplv2
18 *
19 * There are special exceptions to the terms and conditions of the GPL as
20 * it is applied to this Source Code. View the full text of the exception
21 * in the file doc/FLOSS-exception.txt in this software distribution, or
22 * online at http://secondlifegrid.net/programs/open_source/licensing/flossexception
23 *
24 * By copying, modifying or distributing this software, you acknowledge
25 * that you have read and understood your obligations described above,
26 * and agree to abide by those obligations.
27 *
28 * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO
29 * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
30 * COMPLETENESS OR PERFORMANCE.
31 * $/LicenseInfo$
32 */
33
34#include "linden_common.h"
35#include "lllog.h"
36
37#include "llapp.h"
38#include "llsd.h"
39#include "llsdserialize.h"
40
41
42class LLLogImpl
43{
44public:
45 LLLogImpl(LLApp* app) : mApp(app) {}
46 ~LLLogImpl() {}
47
48 void log(const std::string message, LLSD& info);
49 bool useLegacyLogMessage(const std::string message);
50
51private:
52 LLApp* mApp;
53};
54
55
56//@brief Function to log a message to syslog for streambase to collect.
57void LLLogImpl::log(const std::string message, LLSD& info)
58{
59 static S32 sequence = 0;
60 LLSD log_config = mApp->getOption("log-messages");
61 if (log_config.has(message))
62 {
63 LLSD message_config = log_config[message];
64 if (message_config.has("use-syslog"))
65 {
66 if (! message_config["use-syslog"].asBoolean())
67 {
68 return;
69 }
70 }
71 }
72 llinfos << "LLLOGMESSAGE (" << (sequence++) << ") " << message << " " << LLSDNotationStreamer(info) << llendl;
73}
74
75//@brief Function to check if specified legacy log message should be sent.
76bool LLLogImpl::useLegacyLogMessage(const std::string message)
77{
78 LLSD log_config = mApp->getOption("log-messages");
79 if (log_config.has(message))
80 {
81 LLSD message_config = log_config[message];
82 if (message_config.has("use-legacy"))
83 {
84 return message_config["use-legacy"].asBoolean();
85 }
86 }
87 return true;
88}
89
90
91LLLog::LLLog(LLApp* app)
92{
93 mImpl = new LLLogImpl(app);
94}
95
96LLLog::~LLLog()
97{
98 delete mImpl;
99 mImpl = NULL;
100}
101
102void LLLog::log(const std::string message, LLSD& info)
103{
104 if (mImpl) mImpl->log(message, info);
105}
106
107bool LLLog::useLegacyLogMessage(const std::string message)
108{
109 if (mImpl)
110 {
111 return mImpl->useLegacyLogMessage(message);
112 }
113 return true;
114}
115