Mercurial > hg > orthanc-wsi
diff Resources/Orthanc/Core/Logging.cpp @ 92:4b0e0f7c9957
sync
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Fri, 23 Dec 2016 16:06:05 +0100 |
parents | 7a3853d51c45 |
children | ff0ef01c332c |
line wrap: on
line diff
--- a/Resources/Orthanc/Core/Logging.cpp Thu Dec 22 20:18:34 2016 +0100 +++ b/Resources/Orthanc/Core/Logging.cpp Fri Dec 23 16:06:05 2016 +0100 @@ -73,7 +73,74 @@ } } -#else + +#elif ORTHANC_ENABLE_LOGGING_PLUGIN == 1 + +/********************************************************* + * Logger compatible with the Orthanc plugin SDK + *********************************************************/ + +#include <boost/lexical_cast.hpp> + +namespace Orthanc +{ + namespace Logging + { + static OrthancPluginContext* context_ = NULL; + + void Initialize(OrthancPluginContext* context) + { + context_ = context_; + } + + InternalLogger::InternalLogger(const char* level, + const char* file /* ignored */, + int line /* ignored */) : + level_(level) + { + } + + InternalLogger::~InternalLogger() + { + if (context_ != NULL) + { + if (level_ == "ERROR") + { + OrthancPluginLogError(context_, message_.c_str()); + } + else if (level_ == "WARNING") + { + OrthancPluginLogWarning(context_, message_.c_str()); + } + else if (level_ == "INFO") + { + OrthancPluginLogInfo(context_, message_.c_str()); + } + } + } + + InternalLogger& InternalLogger::operator<< (const std::string& message) + { + message_ += message; + return *this; + } + + InternalLogger& InternalLogger::operator<< (const char* message) + { + message_ += std::string(message); + return *this; + } + + InternalLogger& InternalLogger::operator<< (int message) + { + message_ += boost::lexical_cast<std::string>(message); + return *this; + } + } +} + + +#else /* ORTHANC_ENABLE_LOGGING_PLUGIN == 0 && ORTHANC_ENABLE_LOGGING == 1 */ /********************************************************* * Internal logger of Orthanc, that mimics some