summaryrefslogtreecommitdiff
path: root/lib/common/Logging.cpp
diff options
context:
space:
mode:
authorChris Wilson <chris+github@qwirx.com>2008-03-01 22:54:56 +0000
committerChris Wilson <chris+github@qwirx.com>2008-03-01 22:54:56 +0000
commit69bb86cd6a6ca5f914b8d35bb42501f2b73377d0 (patch)
tree2da6a7b530e68469eb44a8dfed44cfaa0a67d3c5 /lib/common/Logging.cpp
parentac8a5801e74636086108276dce7f15a4c1951728 (diff)
Add support for logging just to syslog (not console) at a given
priority.
Diffstat (limited to 'lib/common/Logging.cpp')
-rw-r--r--lib/common/Logging.cpp25
1 files changed, 25 insertions, 0 deletions
diff --git a/lib/common/Logging.cpp b/lib/common/Logging.cpp
index 9b9721a8..f49ab765 100644
--- a/lib/common/Logging.cpp
+++ b/lib/common/Logging.cpp
@@ -148,6 +148,31 @@ void Logging::Log(Log::Level level, const std::string& rFile,
}
}
+void Logging::LogToSyslog(Log::Level level, const std::string& rFile,
+ int line, const std::string& rMessage)
+{
+ if (!sLogToSyslog)
+ {
+ return;
+ }
+
+ if (level > sGlobalLevel)
+ {
+ return;
+ }
+
+ std::string newMessage;
+
+ if (sContextSet)
+ {
+ newMessage += "[" + sContext + "] ";
+ }
+
+ newMessage += rMessage;
+
+ spSyslog->Log(level, rFile, line, newMessage);
+}
+
void Logging::SetContext(std::string context)
{
sContext = context;