[Box Backup-commit] COMMIT r1252 - box/chris/merge/lib/common

boxbackup-dev@fluffy.co.uk boxbackup-dev@fluffy.co.uk
Mon, 15 Jan 2007 23:48:13 +0000


Author: chris
Date: 2007-01-15 23:48:12 +0000 (Mon, 15 Jan 2007)
New Revision: 1252

Modified:
   box/chris/merge/lib/common/Logging.cpp
   box/chris/merge/lib/common/Logging.h
Log:
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)


Modified: box/chris/merge/lib/common/Logging.cpp
===================================================================
--- box/chris/merge/lib/common/Logging.cpp	2007-01-15 22:10:30 UTC (rev 1251)
+++ box/chris/merge/lib/common/Logging.cpp	2007-01-15 23:48:12 UTC (rev 1252)
@@ -23,7 +23,7 @@
 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::Log(Log::Level level, const std::string& rFile, 
 	int line, const std::string& rMessage)
 {
+	if (level > sGlobalLevel)
+	{
+		return;
+	}
+
 	std::string newMessage;
 	
 	if (sContextSet)

Modified: box/chris/merge/lib/common/Logging.h
===================================================================
--- box/chris/merge/lib/common/Logging.h	2007-01-15 22:10:30 UTC (rev 1251)
+++ box/chris/merge/lib/common/Logging.h	2007-01-15 23:48:12 UTC (rev 1252)
@@ -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 @@
 	Log::Level mCurrentLevel;
 	
 	public:
-	Logger() : mCurrentLevel(Log::WARNING) { }
+	Logger() : mCurrentLevel(Log::EVERYTHING) { }
 	virtual ~Logger() { }
 	
 	virtual bool Log(Log::Level level, const std::string& rFile,