# HG changeset patch # User Sebastien Jodogne # Date 1439902661 -7200 # Node ID 0dba274074eb3f48708e5065811c9d11ab96538c # Parent 2c7d5eb588e6dcee17eefba9c51769f19666d628 standalone logging diff -r 2c7d5eb588e6 -r 0dba274074eb Core/Logging.cpp --- a/Core/Logging.cpp Mon Aug 17 15:57:44 2015 +0200 +++ b/Core/Logging.cpp Tue Aug 18 14:57:41 2015 +0200 @@ -33,10 +33,35 @@ #include "PrecompiledHeaders.h" #include "Logging.h" -#if ORTHANC_ENABLE_LOGGING == 1 +#if ORTHANC_ENABLE_LOGGING != 1 + +namespace Orthanc +{ + namespace Logging + { + void Initialize() + { + } + + void Finalize() + { + } + void EnableInfoLevel(bool enabled) + { + } -#if ORTHANC_ENABLE_GOOGLE_LOG == 1 + void EnableTraceLevel(bool enabled) + { + } + + void SetTargetFolder(const std::string& path) + { + } + } +} + +#elif ORTHANC_ENABLE_GOOGLE_LOG == 1 /********************************************************* * Wrapper around Google Log @@ -393,7 +418,4 @@ } } -#endif - - #endif // ORTHANC_ENABLE_LOGGING diff -r 2c7d5eb588e6 -r 0dba274074eb Core/Logging.h --- a/Core/Logging.h Mon Aug 17 15:57:44 2015 +0200 +++ b/Core/Logging.h Tue Aug 18 14:57:41 2015 +0200 @@ -32,18 +32,7 @@ #pragma once -#if ORTHANC_ENABLE_LOGGING == 1 - -#if ORTHANC_ENABLE_GOOGLE_LOG == 1 -# include // Including this fixes a problem in glog for recent releases of MinGW -# include -#else -# include -# include -# define LOG(level) ::Orthanc::Logging::InternalLogger(#level, __FILE__, __LINE__) -# define VLOG(level) ::Orthanc::Logging::InternalLogger("TRACE", __FILE__, __LINE__) -#endif - +#include namespace Orthanc { @@ -59,7 +48,6 @@ void SetTargetFolder(const std::string& path); -#if ORTHANC_ENABLE_GOOGLE_LOG != 1 struct NullStream : public std::ostream { NullStream() : @@ -67,8 +55,37 @@ std::ostream(0) { } + + std::ostream& operator<< (const std::string& message) + { + return *this; + } }; + } +} + +#if ORTHANC_ENABLE_LOGGING != 1 + +# define LOG(level) ::Orthanc::Logging::NullStream() +# define VLOG(level) ::Orthanc::Logging::NullStream() + +#else /* ORTHANC_ENABLE_LOGGING == 1 */ + +#if ORTHANC_ENABLE_GOOGLE_LOG == 1 +# include // Including this fixes a problem in glog for recent releases of MinGW +# include +#else +# include +# define LOG(level) ::Orthanc::Logging::InternalLogger(#level, __FILE__, __LINE__) +# define VLOG(level) ::Orthanc::Logging::InternalLogger("TRACE", __FILE__, __LINE__) +#endif + +#if ORTHANC_ENABLE_GOOGLE_LOG != 1 +namespace Orthanc +{ + namespace Logging + { class InternalLogger { private: @@ -88,8 +105,8 @@ return (*stream_) << message; } }; -#endif } } +#endif #endif // ORTHANC_ENABLE_LOGGING