Mercurial > hg > orthanc
diff OrthancFramework/Sources/Logging.h @ 4268:0ae2ca210077
new macro TLOG() to replace VLOG() for trace logs with a category
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Mon, 02 Nov 2020 14:48:15 +0100 |
parents | bf7b9edf6b81 |
children | c7bd2f21ccc3 |
line wrap: on
line diff
--- a/OrthancFramework/Sources/Logging.h Sun Nov 01 12:43:18 2020 +0100 +++ b/OrthancFramework/Sources/Logging.h Mon Nov 02 14:48:15 2020 +0100 @@ -51,6 +51,13 @@ LogLevel_INFO, LogLevel_TRACE }; + + enum TraceCategory + { + TraceCategory_GENERIC, + TraceCategory_SQLITE, + TraceCategory_DICOM + }; ORTHANC_PUBLIC const char* EnumerationToString(LogLevel level); @@ -97,14 +104,26 @@ } + +/** + * NB: The macro "VLOG(unused)" is for backward compatibility with + * Orthanc <= 1.8.0. + **/ + #if ORTHANC_ENABLE_LOGGING != 1 -# define LOG(level) ::Orthanc::Logging::NullStream() -# define VLOG(level) ::Orthanc::Logging::NullStream() +# define LOG(level) ::Orthanc::Logging::NullStream() +# define VLOG(unused) ::Orthanc::Logging::NullStream() +# define TLOG(category) ::Orthanc::Logging::NullStream() #else /* ORTHANC_ENABLE_LOGGING == 1 */ -# define LOG(level) ::Orthanc::Logging::InternalLogger \ - (::Orthanc::Logging::LogLevel_ ## level, __FILE__, __LINE__) -# define VLOG(level) ::Orthanc::Logging::InternalLogger \ - (::Orthanc::Logging::LogLevel_TRACE, __FILE__, __LINE__) +# define LOG(level) ::Orthanc::Logging::InternalLogger \ + (::Orthanc::Logging::LogLevel_ ## level, \ + ::Orthanc::Logging::TraceCategory_GENERIC, __FILE__, __LINE__) +# define VLOG(unused) ::Orthanc::Logging::InternalLogger \ + (::Orthanc::Logging::LogLevel_TRACE, \ + ::Orthanc::Logging::TraceCategory_GENERIC, __FILE__, __LINE__) +# define TLOG(category) ::Orthanc::Logging::InternalLogger \ + (::Orthanc::Logging::LogLevel_TRACE, \ + ::Orthanc::Logging::TraceCategory_ ## category, __FILE__, __LINE__) #endif @@ -125,13 +144,16 @@ { private: LogLevel level_; + TraceCategory category_; std::stringstream messageStream_; public: InternalLogger(LogLevel level, + TraceCategory category, const char* file /* ignored */, int line /* ignored */) : - level_(level) + level_(level), + category_(category) { } @@ -169,11 +191,13 @@ private: boost::mutex::scoped_lock lock_; LogLevel level_; + TraceCategory category_; std::unique_ptr<std::stringstream> pluginStream_; std::ostream* stream_; public: InternalLogger(LogLevel level, + TraceCategory category, const char* file, int line);