diff options
Diffstat (limited to 'lib/common/Logging.cpp')
-rw-r--r-- | lib/common/Logging.cpp | 79 |
1 files changed, 79 insertions, 0 deletions
diff --git a/lib/common/Logging.cpp b/lib/common/Logging.cpp index 296443ea..4a7e5e0a 100644 --- a/lib/common/Logging.cpp +++ b/lib/common/Logging.cpp @@ -22,6 +22,12 @@ #ifdef HAVE_UNISTD_H #include <unistd.h> #endif +<<<<<<< HEAD +======= +#ifdef WIN32 + #include <process.h> +#endif +>>>>>>> 0.12 #include <cstring> #include <iomanip> @@ -43,6 +49,15 @@ Log::Level Logging::sGlobalLevel = Log::EVERYTHING; Logging Logging::sGlobalLogging; //automatic initialisation std::string Logging::sProgramName; +<<<<<<< HEAD +======= +HideSpecificExceptionGuard::SuppressedExceptions_t + HideSpecificExceptionGuard::sSuppressedExceptions; + +int Logging::Guard::sGuardCount = 0; +Log::Level Logging::Guard::sOriginalLevel = Log::INVALID; + +>>>>>>> 0.12 Logging::Logging() { ASSERT(!spConsole); @@ -244,6 +259,15 @@ Logger::~Logger() Logging::Remove(this); } +<<<<<<< HEAD +======= +bool Logger::IsEnabled(Log::Level level) +{ + return Logging::IsEnabled(level) && + (int)mCurrentLevel >= (int)level; +} + +>>>>>>> 0.12 bool Console::sShowTime = false; bool Console::sShowTimeMicros = false; bool Console::sShowTag = false; @@ -343,11 +367,28 @@ bool Console::Log(Log::Level level, const std::string& rFile, #ifdef WIN32 std::string output = buf.str(); +<<<<<<< HEAD ConvertUtf8ToConsole(output.c_str(), output); fprintf(target, "%s\n", output.c_str()); #else fprintf(target, "%s\n", buf.str().c_str()); #endif +======= + if(ConvertUtf8ToConsole(output.c_str(), output) == false) + { + fprintf(target, "%s (and failed to convert to console encoding)\n", + output.c_str()); + } + else + { + fprintf(target, "%s\n", output.c_str()); + } + #else + fprintf(target, "%s\n", buf.str().c_str()); + #endif + + fflush(target); +>>>>>>> 0.12 return true; } @@ -446,13 +487,28 @@ int Syslog::GetNamedFacility(const std::string& rFacility) bool FileLogger::Log(Log::Level Level, const std::string& rFile, int line, std::string& rMessage) { +<<<<<<< HEAD +======= + if (mLogFile.StreamClosed()) + { + /* skip this logger to allow logging failure to open + the log file, without causing an infinite loop */ + return true; + } + +>>>>>>> 0.12 if (Level > GetLevel()) { return true; } /* avoid infinite loop if this throws an exception */ +<<<<<<< HEAD Logging::Remove(this); +======= + Log::Level oldLevel = GetLevel(); + Filter(Log::NOTHING); +>>>>>>> 0.12 std::ostringstream buf; buf << FormatTime(GetCurrentBoxTime(), true, false); @@ -492,7 +548,12 @@ bool FileLogger::Log(Log::Level Level, const std::string& rFile, mLogFile.Write(output.c_str(), output.length()); +<<<<<<< HEAD Logging::Add(this); +======= + // no infinite loop, reset to saved logging level + Filter(oldLevel); +>>>>>>> 0.12 return true; } @@ -516,3 +577,21 @@ std::string PrintEscapedBinaryData(const std::string& rInput) return output.str(); } +<<<<<<< HEAD +======= + +bool HideSpecificExceptionGuard::IsHidden(int type, int subtype) +{ + for (SuppressedExceptions_t::iterator + i = sSuppressedExceptions.begin(); + i != sSuppressedExceptions.end(); i++) + { + if(i->first == type && i->second == subtype) + { + return true; + } + } + return false; +} + +>>>>>>> 0.12 |