diff options
author | Chris Wilson <chris+github@qwirx.com> | 2007-01-15 23:48:12 +0000 |
---|---|---|
committer | Chris Wilson <chris+github@qwirx.com> | 2007-01-15 23:48:12 +0000 |
commit | 60e8f1ea15e69b987ec916fd006174b345444644 (patch) | |
tree | f8c331ccf5bc4c41ffe4031509a7f154b3003845 | |
parent | e04804ca2f08402ac6b8fa7d043767eb42738de7 (diff) |
Add a new logging level, NOTICE, between INFO and WARNING (justification:
we need two levels of output for LogAllFileAccess, neither of which are
warnings, one is very verbose, but must not be compiled out like TRACE).
Make Loggers default to logging everything.
Make the global log level filter work. (refs #3)
-rw-r--r-- | lib/common/Logging.cpp | 7 | ||||
-rw-r--r-- | lib/common/Logging.h | 6 |
2 files changed, 10 insertions, 3 deletions
diff --git a/lib/common/Logging.cpp b/lib/common/Logging.cpp index dad96126..3e2062da 100644 --- a/lib/common/Logging.cpp +++ b/lib/common/Logging.cpp @@ -23,7 +23,7 @@ std::vector<Logger*> Logging::sLoggers; std::string Logging::sContext; Console Logging::sConsole; Syslog Logging::sSyslog; -Log::Level Logging::sGlobalLevel; +Log::Level Logging::sGlobalLevel = Log::EVERYTHING; void Logging::ToSyslog(bool enabled) { @@ -95,6 +95,11 @@ void Logging::Remove(Logger* pOldLogger) void Logging::Log(Log::Level level, const std::string& rFile, int line, const std::string& rMessage) { + if (level > sGlobalLevel) + { + return; + } + std::string newMessage; if (sContextSet) diff --git a/lib/common/Logging.h b/lib/common/Logging.h index e7a11d36..c85b4586 100644 --- a/lib/common/Logging.h +++ b/lib/common/Logging.h @@ -34,6 +34,7 @@ #define BOX_FATAL(stuff) BOX_LOG(Log::FATAL, stuff) #define BOX_ERROR(stuff) BOX_LOG(Log::ERROR, stuff) #define BOX_WARNING(stuff) BOX_LOG(Log::WARNING, stuff) +#define BOX_NOTICE(stuff) BOX_LOG(Log::NOTICE, stuff) #define BOX_INFO(stuff) BOX_LOG(Log::INFO, stuff) #if defined NDEBUG && ! defined COMPILE_IN_TRACES #define BOX_TRACE(stuff) @@ -43,7 +44,8 @@ namespace Log { - enum Level { NOTHING = 1, FATAL, ERROR, WARNING, INFO, TRACE, EVERYTHING }; + enum Level { NOTHING = 1, FATAL, ERROR, WARNING, NOTICE, INFO, TRACE, + EVERYTHING }; } // -------------------------------------------------------------------------- @@ -61,7 +63,7 @@ class Logger Log::Level mCurrentLevel; public: - Logger() : mCurrentLevel(Log::WARNING) { } + Logger() : mCurrentLevel(Log::EVERYTHING) { } virtual ~Logger() { } virtual bool Log(Log::Level level, const std::string& rFile, |