comparison Core/Logging.h @ 3993:7e8bfda62b43

fix msvc builds
author Sebastien Jodogne <s.jodogne@gmail.com>
date Fri, 05 Jun 2020 16:52:09 +0200
parents f9863630ec7f
children 1f405a3fdeca
comparison
equal deleted inserted replaced
3992:f9863630ec7f 3993:7e8bfda62b43
67 namespace Orthanc 67 namespace Orthanc
68 { 68 {
69 namespace Logging 69 namespace Logging
70 { 70 {
71 #if ORTHANC_ENABLE_LOGGING_PLUGIN == 1 71 #if ORTHANC_ENABLE_LOGGING_PLUGIN == 1
72 void Initialize(OrthancPluginContext* context) ORTHANC_PUBLIC; 72 ORTHANC_PUBLIC void Initialize(OrthancPluginContext* context);
73 #else 73 #else
74 void Initialize() ORTHANC_PUBLIC; 74 ORTHANC_PUBLIC void Initialize();
75 #endif 75 #endif
76 76
77 void Finalize() ORTHANC_PUBLIC; 77 ORTHANC_PUBLIC void Finalize();
78 78
79 void Reset() ORTHANC_PUBLIC; 79 ORTHANC_PUBLIC void Reset();
80 80
81 void Flush() ORTHANC_PUBLIC; 81 ORTHANC_PUBLIC void Flush();
82 82
83 void EnableInfoLevel(bool enabled) ORTHANC_PUBLIC; 83 ORTHANC_PUBLIC void EnableInfoLevel(bool enabled);
84 84
85 void EnableTraceLevel(bool enabled) ORTHANC_PUBLIC; 85 ORTHANC_PUBLIC void EnableTraceLevel(bool enabled);
86 86
87 bool IsTraceLevelEnabled() ORTHANC_PUBLIC; 87 ORTHANC_PUBLIC bool IsTraceLevelEnabled();
88 88
89 bool IsInfoLevelEnabled() ORTHANC_PUBLIC; 89 ORTHANC_PUBLIC bool IsInfoLevelEnabled();
90 90
91 void SetTargetFile(const std::string& path) ORTHANC_PUBLIC; 91 ORTHANC_PUBLIC void SetTargetFile(const std::string& path);
92 92
93 void SetTargetFolder(const std::string& path) ORTHANC_PUBLIC; 93 ORTHANC_PUBLIC void SetTargetFolder(const std::string& path);
94 94
95 #if ORTHANC_ENABLE_LOGGING_STDIO == 1 95 #if ORTHANC_ENABLE_LOGGING_STDIO == 1
96 typedef void (*LoggingFunction)(const char*); 96 typedef void (*LoggingFunction)(const char*);
97 void SetErrorWarnInfoTraceLoggingFunctions( 97 void SetErrorWarnInfoTraceLoggingFunctions(
98 LoggingFunction errorLogFunc, 98 LoggingFunction errorLogFunc,
126 126
127 #elif (ORTHANC_ENABLE_LOGGING_PLUGIN == 1 || \ 127 #elif (ORTHANC_ENABLE_LOGGING_PLUGIN == 1 || \
128 ORTHANC_ENABLE_LOGGING_STDIO == 1) 128 ORTHANC_ENABLE_LOGGING_STDIO == 1)
129 129
130 # include <boost/noncopyable.hpp> 130 # include <boost/noncopyable.hpp>
131 # define LOG(level) ::Orthanc::Logging::InternalLogger \ 131 # define LOG(level) ::Orthanc::Logging::InternalLogger \
132 (::Orthanc::Logging::InternalLevel_ ## level, __FILE__, __LINE__) 132 (::Orthanc::Logging::InternalLevel_ ## level, __FILE__, __LINE__)
133 # define VLOG(level) ::Orthanc::Logging::InternalLogger \ 133 # define VLOG(level) ::Orthanc::Logging::InternalLogger \
134 (::Orthanc::Logging::InternalLevel_TRACE, __FILE__, __LINE__) 134 (::Orthanc::Logging::InternalLevel_TRACE, __FILE__, __LINE__)
135 135
136 namespace Orthanc 136 namespace Orthanc
137 { 137 {
138 namespace Logging 138 namespace Logging
157 int line); 157 int line);
158 158
159 ~InternalLogger(); 159 ~InternalLogger();
160 160
161 template <typename T> 161 template <typename T>
162 InternalLogger& operator<< (const T& message) 162 InternalLogger& operator<< (const T& message)
163 { 163 {
164 messageStream_ << message; 164 messageStream_ << message;
165 return *this; 165 return *this;
166 } 166 }
167 }; 167 };
196 int line); 196 int line);
197 197
198 ~InternalLogger(); 198 ~InternalLogger();
199 199
200 template <typename T> 200 template <typename T>
201 std::ostream& operator<< (const T& message) 201 std::ostream& operator<< (const T& message)
202 { 202 {
203 return (*stream_) << boost::lexical_cast<std::string>(message); 203 return (*stream_) << boost::lexical_cast<std::string>(message);
204 } 204 }
205 }; 205 };
206 206
207 /** 207 /**
208 opaque pointer that represents the state of the logging configuration 208 opaque pointer that represents the state of the logging configuration
209 */ 209 */
210 typedef void* LoggingMemento; 210 typedef void* LoggingMemento;
211 211
212 /** 212 /**
213 Returns an object that contains the logging configuration. 213 Returns an object that contains the logging configuration.
214 214
215 This function allocates resources that you must dispose of by 215 This function allocates resources that you must dispose of by
216 using either RestoreLoggingMemento or DiscardLoggingMemento. 216 using either RestoreLoggingMemento or DiscardLoggingMemento.
217 217
218 This function is only to be used by tests. 218 This function is only to be used by tests.
219 */ 219 */
220 LoggingMemento CreateLoggingMemento() ORTHANC_PUBLIC; 220 ORTHANC_PUBLIC LoggingMemento CreateLoggingMemento();
221 221
222 /** 222 /**
223 Restores the logging configuration. The logging system is restored in 223 Restores the logging configuration. The logging system is restored in
224 the state it was in when the memento object was created through 224 the state it was in when the memento object was created through
225 GetLoggingMemento(). 225 GetLoggingMemento().
226 226
227 After calling this function, the memento object may not be used 227 After calling this function, the memento object may not be used
228 again 228 again
229 229
230 This function is only to be used by tests. 230 This function is only to be used by tests.
231 */ 231 */
232 void RestoreLoggingMemento(LoggingMemento memento) ORTHANC_PUBLIC; 232 ORTHANC_PUBLIC void RestoreLoggingMemento(LoggingMemento memento);
233 233
234 /** 234 /**
235 Call this function if you do not plan on restoring the logging 235 Call this function if you do not plan on restoring the logging
236 configuration state that you captured with CreateLoggingMemento 236 configuration state that you captured with CreateLoggingMemento
237 237
238 This function is only to be used by tests. 238 This function is only to be used by tests.
239 */ 239 */
240 void DiscardLoggingMemento(LoggingMemento memento) ORTHANC_PUBLIC; 240 ORTHANC_PUBLIC void DiscardLoggingMemento(LoggingMemento memento);
241 241
242 /** 242 /**
243 Set custom logging streams for the error, warning and info logs. 243 Set custom logging streams for the error, warning and info logs.
244 This function may not be called if a log file or folder has been 244 This function may not be called if a log file or folder has been
245 set beforehand. All three pointers must be valid and cannot be NULL. 245 set beforehand. All three pointers must be valid and cannot be NULL.
246 246
247 Please ensure the supplied streams remain alive and valid as long as 247 Please ensure the supplied streams remain alive and valid as long as
248 logging calls are performed. 248 logging calls are performed.
249 249
250 In order to prevent dangling pointer usage, it is recommended to call 250 In order to prevent dangling pointer usage, it is recommended to call
251 Orthanc::Logging::Reset() before the stream objects are destroyed and 251 Orthanc::Logging::Reset() before the stream objects are destroyed and
252 the pointers become invalid. 252 the pointers become invalid.
253 */ 253 */
254 void SetErrorWarnInfoLoggingStreams(std::ostream* errorStream, 254 ORTHANC_PUBLIC void SetErrorWarnInfoLoggingStreams(std::ostream* errorStream,
255 std::ostream* warningStream, 255 std::ostream* warningStream,
256 std::ostream* infoStream) ORTHANC_PUBLIC; 256 std::ostream* infoStream);
257 257
258 #ifdef __EMSCRIPTEN__ 258 #ifdef __EMSCRIPTEN__
259 /** 259 /**
260 This function will change the logging streams so that the logging functions 260 This function will change the logging streams so that the logging functions
261 provided by emscripten html5.h API functions are used : it will change the 261 provided by emscripten html5.h API functions are used : it will change the
262 error_, warning_ and info_ stream objects so that their operator<< writes 262 error_, warning_ and info_ stream objects so that their operator<< writes
263 into the browser console using emscripten_console_error(), 263 into the browser console using emscripten_console_error(),
264 emscripten_console_warn() and emscripten_console_log(). This will allow for 264 emscripten_console_warn() and emscripten_console_log(). This will allow for
265 logging levels to be correctly handled by the browser when the code executes 265 logging levels to be correctly handled by the browser when the code executes
266 in Web Assembly 266 in Web Assembly
267 */ 267 */
268 void EnableEmscriptenLogging() ORTHANC_PUBLIC; 268 ORTHANC_PUBLIC void EnableEmscriptenLogging();
269 #endif 269 #endif
270 } 270 }
271 } 271 }
272 272
273 #endif // ORTHANC_ENABLE_LOGGING 273 #endif // ORTHANC_ENABLE_LOGGING