comparison Core/Logging.h @ 4017:c783f4f29390

log using emscripten
author Sebastien Jodogne <s.jodogne@gmail.com>
date Mon, 08 Jun 2020 18:15:31 +0200
parents 27628b0f6ada
children
comparison
equal deleted inserted replaced
4016:c675d77b82ab 4017:c783f4f29390
107 } 107 }
108 } 108 }
109 109
110 110
111 #if ORTHANC_ENABLE_LOGGING != 1 111 #if ORTHANC_ENABLE_LOGGING != 1
112 #define LOG(level) ::Orthanc::Logging::NullStream() 112 # define LOG(level) ::Orthanc::Logging::NullStream()
113 #define VLOG(level) ::Orthanc::Logging::NullStream() 113 # define VLOG(level) ::Orthanc::Logging::NullStream()
114
115 #else /* ORTHANC_ENABLE_LOGGING == 1 */ 114 #else /* ORTHANC_ENABLE_LOGGING == 1 */
116 115 # define LOG(level) ::Orthanc::Logging::InternalLogger \
117 #define LOG(level) ::Orthanc::Logging::InternalLogger \
118 (::Orthanc::Logging::LogLevel_ ## level, __FILE__, __LINE__) 116 (::Orthanc::Logging::LogLevel_ ## level, __FILE__, __LINE__)
119 #define VLOG(level) ::Orthanc::Logging::InternalLogger \ 117 # define VLOG(level) ::Orthanc::Logging::InternalLogger \
120 (::Orthanc::Logging::LogLevel_TRACE, __FILE__, __LINE__) 118 (::Orthanc::Logging::LogLevel_TRACE, __FILE__, __LINE__)
119 #endif
120
121
122
123 #if (ORTHANC_ENABLE_LOGGING == 1 && \
124 ORTHANC_ENABLE_LOGGING_STDIO == 1)
125 // This is notably for WebAssembly
126
127 #include <boost/lexical_cast.hpp>
128 #include <boost/noncopyable.hpp>
129 #include <sstream>
130
131 namespace Orthanc
132 {
133 namespace Logging
134 {
135 class ORTHANC_PUBLIC InternalLogger : public boost::noncopyable
136 {
137 private:
138 LogLevel level_;
139 std::stringstream messageStream_;
140
141 public:
142 InternalLogger(LogLevel level,
143 const char* file /* ignored */,
144 int line /* ignored */) :
145 level_(level)
146 {
147 }
148
149 ~InternalLogger();
150
151 template <typename T>
152 std::ostream& operator<< (const T& message)
153 {
154 return messageStream_ << boost::lexical_cast<std::string>(message);
155 }
156 };
157 }
158 }
159
160 #endif
161
162
163
164 #if (ORTHANC_ENABLE_LOGGING == 1 && \
165 ORTHANC_ENABLE_LOGGING_STDIO == 0)
121 166
122 #include "Compatibility.h" // For std::unique_ptr<> 167 #include "Compatibility.h" // For std::unique_ptr<>
123 168
124 #include <boost/lexical_cast.hpp> 169 #include <boost/lexical_cast.hpp>
125 #include <boost/noncopyable.hpp> 170 #include <boost/noncopyable.hpp>