diff options
-rw-r--r-- | src/main/cpp/loglog.cpp | 95 |
1 files changed, 58 insertions, 37 deletions
diff --git a/src/main/cpp/loglog.cpp b/src/main/cpp/loglog.cpp index d3498f2..dbe5d37 100644 --- a/src/main/cpp/loglog.cpp +++ b/src/main/cpp/loglog.cpp @@ -30,92 +30,113 @@ using namespace log4cxx; using namespace log4cxx::helpers; -LogLog::LogLog() : mutex(APRInitializer::getRootPool()) { +LogLog::LogLog() : mutex(APRInitializer::getRootPool()) +{ synchronized sync(mutex); - debugEnabled = false; - quietMode = false; + + debugEnabled = false; + quietMode = false; } -LogLog& LogLog::getInstance() { +LogLog& LogLog::getInstance() +{ static LogLog internalLogger; + return internalLogger; } - void LogLog::setInternalDebugging(bool debugEnabled1) { - synchronized sync(getInstance().mutex); - getInstance().debugEnabled = debugEnabled1; + synchronized sync(getInstance().mutex); + + getInstance().debugEnabled = debugEnabled1; } void LogLog::debug(const LogString& msg) { - synchronized sync(getInstance().mutex); - if(getInstance().debugEnabled && !getInstance().quietMode) - { - emit(msg); - } + synchronized sync(getInstance().mutex); + + if (getInstance().debugEnabled && !getInstance().quietMode) + { + emit(msg); + } } void LogLog::debug(const LogString& msg, const std::exception& e) { - synchronized sync(getInstance().mutex); - debug(msg); - emit(e); + synchronized sync(getInstance().mutex); + + debug(msg); + emit(e); } void LogLog::error(const LogString& msg) { - synchronized sync(getInstance().mutex); - if(!getInstance().quietMode) { - emit(msg); - } + synchronized sync(getInstance().mutex); + + if (!getInstance().quietMode) + { + emit(msg); + } } void LogLog::error(const LogString& msg, const std::exception& e) { - synchronized sync(getInstance().mutex); - error(msg); - emit(e); + synchronized sync(getInstance().mutex); + + error(msg); + emit(e); } void LogLog::setQuietMode(bool quietMode1) { - synchronized sync(getInstance().mutex); - getInstance().quietMode = quietMode1; + synchronized sync(getInstance().mutex); + + getInstance().quietMode = quietMode1; } void LogLog::warn(const LogString& msg) { - synchronized sync(getInstance().mutex); - if(!getInstance().quietMode) { - emit(msg); - } + synchronized sync(getInstance().mutex); + + if (!getInstance().quietMode) + { + emit(msg); + } } void LogLog::warn(const LogString& msg, const std::exception& e) { - synchronized sync(getInstance().mutex); - warn(msg); - emit(e); + synchronized sync(getInstance().mutex); + + warn(msg); + emit(e); } -void LogLog::emit(const LogString& msg) { +void LogLog::emit(const LogString& msg) +{ LogString out(LOG4CXX_STR("log4cxx: ")); + out.append(msg); - out.append(1, (logchar) 0x0A); + out.append(1, (logchar) 0x0A); + SystemErrWriter::write(out); } -void LogLog::emit(const std::exception& ex) { +void LogLog::emit(const std::exception& ex) +{ LogString out(LOG4CXX_STR("log4cxx: ")); const char* raw = ex.what(); - if (raw != 0) { + + if (raw != 0) + { Transcoder::decode(raw, out); - } else { + } else + { out.append(LOG4CXX_STR("std::exception::what() == null")); } - out.append(1, (logchar) 0x0A); + out.append(1, (logchar) 0x0A); + SystemErrWriter::write(out); } |