summaryrefslogtreecommitdiff
path: root/lib/common/Logging.h
diff options
context:
space:
mode:
authorChris Wilson <chris+github@qwirx.com>2012-11-27 22:49:18 +0000
committerChris Wilson <chris+github@qwirx.com>2012-11-27 22:49:18 +0000
commit6f845ef4024cb1f68d3af65580819fdc330b4a90 (patch)
tree7bcb08435c1a5b71c390b5e42b5ca3e591937e9c /lib/common/Logging.h
parent54cd5a63fb3d7c6d00f60d4383f9193b01dc7968 (diff)
Allow getting the standard Console and Syslog loggers. Add a Guard class
that can be used to protect against permanent changes to their log levels.
Diffstat (limited to 'lib/common/Logging.h')
-rw-r--r--lib/common/Logging.h23
1 files changed, 22 insertions, 1 deletions
diff --git a/lib/common/Logging.h b/lib/common/Logging.h
index 81062e38..1074b7c3 100644
--- a/lib/common/Logging.h
+++ b/lib/common/Logging.h
@@ -197,8 +197,27 @@ class Logger
virtual const char* GetType() = 0;
Log::Level GetLevel() { return mCurrentLevel; }
-
+ bool IsEnabled(Log::Level level);
+
virtual void SetProgramName(const std::string& rProgramName) = 0;
+
+ class Guard
+ {
+ private:
+ Logger& mLogger;
+ Log::Level mOldLevel;
+
+ public:
+ Guard(Logger& Logger)
+ : mLogger(Logger)
+ {
+ mOldLevel = Logger.GetLevel();
+ }
+ ~Guard()
+ {
+ mLogger.Filter(mOldLevel);
+ }
+ };
};
// --------------------------------------------------------------------------
@@ -306,6 +325,8 @@ class Logging
static void SetProgramName(const std::string& rProgramName);
static std::string GetProgramName() { return sProgramName; }
static void SetFacility(int facility);
+ static Console& GetConsole() { return *spConsole; }
+ static Syslog& GetSyslog() { return *spSyslog; }
class Guard
{