Mercurial > hg > orthanc-wsi
diff Resources/Orthanc/Core/Logging.h @ 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.h Thu Dec 22 20:18:34 2016 +0100 +++ b/Resources/Orthanc/Core/Logging.h Fri Dec 23 16:06:05 2016 +0100 @@ -38,11 +38,27 @@ # error The macro ORTHANC_ENABLE_LOGGING must be defined #endif +#if !defined(ORTHANC_ENABLE_LOGGING_PLUGIN) +# if ORTHANC_ENABLE_LOGGING == 1 +# error The macro ORTHANC_ENABLE_LOGGING_PLUGIN must be defined +# else +# define ORTHANC_ENABLE_LOGGING_PLUGIN 0 +# endif +#endif + +#if ORTHANC_ENABLE_LOGGING_PLUGIN == 1 +# include <orthanc/OrthancCPlugin.h> +#endif + namespace Orthanc { namespace Logging { +#if ORTHANC_ENABLE_LOGGING_PLUGIN == 1 + void Initialize(OrthancPluginContext* context); +#else void Initialize(); +#endif void Finalize(); @@ -86,7 +102,41 @@ # define LOG(level) ::Orthanc::Logging::NullStream() # define VLOG(level) ::Orthanc::Logging::NullStream() -#else /* ORTHANC_ENABLE_LOGGING == 1 */ + +#elif ORTHANC_ENABLE_LOGGING_PLUGIN == 1 + +# include <boost/noncopyable.hpp> +# define LOG(level) ::Orthanc::Logging::InternalLogger(#level, __FILE__, __LINE__) +# define VLOG(level) ::Orthanc::Logging::InternalLogger("TRACE", __FILE__, __LINE__) + +namespace Orthanc +{ + namespace Logging + { + class InternalLogger : public boost::noncopyable + { + private: + std::string level_; + std::string message_; + + public: + InternalLogger(const char* level, + const char* file, + int line); + + ~InternalLogger(); + + InternalLogger& operator<< (const std::string& message); + + InternalLogger& operator<< (const char* message); + + InternalLogger& operator<< (int message); + }; + } +} + + +#else /* ORTHANC_ENABLE_LOGGING_PLUGIN == 0 && ORTHANC_ENABLE_LOGGING == 1 */ # include <boost/thread/mutex.hpp> # define LOG(level) ::Orthanc::Logging::InternalLogger(#level, __FILE__, __LINE__)