Mercurial > hg > orthanc
annotate OrthancFramework/Sources/Logging.h @ 5581:4ad301c35f6e find-refactoring
refactoring
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Sat, 27 Apr 2024 15:02:24 +0200 |
parents | d7eaa568da15 |
children | 4bd7abdfb9cf |
rev | line source |
---|---|
1485 | 1 /** |
2 * Orthanc - A Lightweight, RESTful DICOM Store | |
1900 | 3 * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics |
1485 | 4 * Department, University Hospital of Liege, Belgium |
5485
48b8dae6dc77
upgrade to year 2024
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5450
diff
changeset
|
5 * Copyright (C) 2017-2024 Osimis S.A., Belgium |
48b8dae6dc77
upgrade to year 2024
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5450
diff
changeset
|
6 * Copyright (C) 2021-2024 Sebastien Jodogne, ICTEAM UCLouvain, Belgium |
1485 | 7 * |
8 * This program is free software: you can redistribute it and/or | |
4119
bf7b9edf6b81
re-licensing the OrthancFramework to LGPL, in order to license Stone of Orthanc under LGPL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4044
diff
changeset
|
9 * modify it under the terms of the GNU Lesser General Public License |
bf7b9edf6b81
re-licensing the OrthancFramework to LGPL, in order to license Stone of Orthanc under LGPL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4044
diff
changeset
|
10 * as published by the Free Software Foundation, either version 3 of |
bf7b9edf6b81
re-licensing the OrthancFramework to LGPL, in order to license Stone of Orthanc under LGPL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4044
diff
changeset
|
11 * the License, or (at your option) any later version. |
1485 | 12 * |
13 * This program is distributed in the hope that it will be useful, but | |
14 * WITHOUT ANY WARRANTY; without even the implied warranty of | |
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
4119
bf7b9edf6b81
re-licensing the OrthancFramework to LGPL, in order to license Stone of Orthanc under LGPL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4044
diff
changeset
|
16 * Lesser General Public License for more details. |
1485 | 17 * |
4119
bf7b9edf6b81
re-licensing the OrthancFramework to LGPL, in order to license Stone of Orthanc under LGPL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4044
diff
changeset
|
18 * You should have received a copy of the GNU Lesser General Public |
bf7b9edf6b81
re-licensing the OrthancFramework to LGPL, in order to license Stone of Orthanc under LGPL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4044
diff
changeset
|
19 * License along with this program. If not, see |
bf7b9edf6b81
re-licensing the OrthancFramework to LGPL, in order to license Stone of Orthanc under LGPL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4044
diff
changeset
|
20 * <http://www.gnu.org/licenses/>. |
1485 | 21 **/ |
3992
f9863630ec7f
working on the shared library for Orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3640
diff
changeset
|
22 |
f9863630ec7f
working on the shared library for Orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3640
diff
changeset
|
23 |
1485 | 24 #pragma once |
25 | |
3992
f9863630ec7f
working on the shared library for Orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3640
diff
changeset
|
26 // To have ORTHANC_ENABLE_LOGGING defined if using the shared library |
f9863630ec7f
working on the shared library for Orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3640
diff
changeset
|
27 #include "OrthancFramework.h" |
4313
91554aecff9a
removed a friend method for better abi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4294
diff
changeset
|
28 #include "Compatibility.h" |
3992
f9863630ec7f
working on the shared library for Orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3640
diff
changeset
|
29 |
1551
0dba274074eb
standalone logging
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1507
diff
changeset
|
30 #include <iostream> |
1489 | 31 |
2137
595cf22b3e7e
safety checks of macros
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2134
diff
changeset
|
32 #if !defined(ORTHANC_ENABLE_LOGGING) |
595cf22b3e7e
safety checks of macros
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2134
diff
changeset
|
33 # error The macro ORTHANC_ENABLE_LOGGING must be defined |
595cf22b3e7e
safety checks of macros
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2134
diff
changeset
|
34 #endif |
595cf22b3e7e
safety checks of macros
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2134
diff
changeset
|
35 |
2483
9c54c40eaf25
logging primitives for WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
36 #if !defined(ORTHANC_ENABLE_LOGGING_STDIO) |
9c54c40eaf25
logging primitives for WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
37 # if ORTHANC_ENABLE_LOGGING == 1 |
9c54c40eaf25
logging primitives for WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
38 # error The macro ORTHANC_ENABLE_LOGGING_STDIO must be defined |
9c54c40eaf25
logging primitives for WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
39 # else |
9c54c40eaf25
logging primitives for WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
40 # define ORTHANC_ENABLE_LOGGING_STDIO 0 |
9c54c40eaf25
logging primitives for WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
41 # endif |
9c54c40eaf25
logging primitives for WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
42 #endif |
9c54c40eaf25
logging primitives for WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
43 |
2504 | 44 |
1485 | 45 namespace Orthanc |
46 { | |
47 namespace Logging | |
48 { | |
5561
0b18690c1935
SDK: added OrthancPluginLogMessage to display plugin name + file and line from plugin
Alain Mazy <am@orthanc.team>
parents:
5485
diff
changeset
|
49 // Note: these values must match the ones in OrthancCPlugin.h |
3998
b3f09bc9734b
sharing more code between the loggers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3996
diff
changeset
|
50 enum LogLevel |
3996
c2b9a7a1c74a
ORTHANC_FRAMEWORK_BUILDING_PLUGIN
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3995
diff
changeset
|
51 { |
5561
0b18690c1935
SDK: added OrthancPluginLogMessage to display plugin name + file and line from plugin
Alain Mazy <am@orthanc.team>
parents:
5485
diff
changeset
|
52 LogLevel_ERROR = 0, |
0b18690c1935
SDK: added OrthancPluginLogMessage to display plugin name + file and line from plugin
Alain Mazy <am@orthanc.team>
parents:
5485
diff
changeset
|
53 LogLevel_WARNING = 1, |
0b18690c1935
SDK: added OrthancPluginLogMessage to display plugin name + file and line from plugin
Alain Mazy <am@orthanc.team>
parents:
5485
diff
changeset
|
54 LogLevel_INFO = 2, |
0b18690c1935
SDK: added OrthancPluginLogMessage to display plugin name + file and line from plugin
Alain Mazy <am@orthanc.team>
parents:
5485
diff
changeset
|
55 LogLevel_TRACE = 3 |
3996
c2b9a7a1c74a
ORTHANC_FRAMEWORK_BUILDING_PLUGIN
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3995
diff
changeset
|
56 }; |
4268
0ae2ca210077
new macro TLOG() to replace VLOG() for trace logs with a category
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4119
diff
changeset
|
57 |
4270
251a8b07fa37
logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4269
diff
changeset
|
58 /** |
251a8b07fa37
logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4269
diff
changeset
|
59 * NB: The log level for each category is encoded as a bit |
251a8b07fa37
logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4269
diff
changeset
|
60 * mask. As a consequence, there can be up to 31 log categories |
251a8b07fa37
logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4269
diff
changeset
|
61 * (not 32, as the value GENERIC is reserved for the log commands |
251a8b07fa37
logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4269
diff
changeset
|
62 * that don't fall in a specific category). |
5561
0b18690c1935
SDK: added OrthancPluginLogMessage to display plugin name + file and line from plugin
Alain Mazy <am@orthanc.team>
parents:
5485
diff
changeset
|
63 * Note: these values must match the ones in OrthancCPlugin.h |
4270
251a8b07fa37
logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4269
diff
changeset
|
64 **/ |
4269
c7bd2f21ccc3
new macro CLOG, and sharing more code between logging engines
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4268
diff
changeset
|
65 enum LogCategory |
4268
0ae2ca210077
new macro TLOG() to replace VLOG() for trace logs with a category
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4119
diff
changeset
|
66 { |
4270
251a8b07fa37
logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4269
diff
changeset
|
67 LogCategory_GENERIC = (1 << 0), |
4271
1bd14c900699
LogCategory_PLUGINS
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4270
diff
changeset
|
68 LogCategory_PLUGINS = (1 << 1), |
4294
0923247e69f6
log categories: rest -> http + added lua & jobs
Alain Mazy <alain@mazy.be>
parents:
4275
diff
changeset
|
69 LogCategory_HTTP = (1 << 2), |
4272 | 70 LogCategory_SQLITE = (1 << 3), |
4294
0923247e69f6
log categories: rest -> http + added lua & jobs
Alain Mazy <alain@mazy.be>
parents:
4275
diff
changeset
|
71 LogCategory_DICOM = (1 << 4), |
0923247e69f6
log categories: rest -> http + added lua & jobs
Alain Mazy <alain@mazy.be>
parents:
4275
diff
changeset
|
72 LogCategory_JOBS = (1 << 5), |
4790 | 73 LogCategory_LUA = (1 << 6) |
4268
0ae2ca210077
new macro TLOG() to replace VLOG() for trace logs with a category
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4119
diff
changeset
|
74 }; |
3996
c2b9a7a1c74a
ORTHANC_FRAMEWORK_BUILDING_PLUGIN
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3995
diff
changeset
|
75 |
3998
b3f09bc9734b
sharing more code between the loggers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3996
diff
changeset
|
76 ORTHANC_PUBLIC const char* EnumerationToString(LogLevel level); |
b3f09bc9734b
sharing more code between the loggers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3996
diff
changeset
|
77 |
b3f09bc9734b
sharing more code between the loggers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3996
diff
changeset
|
78 ORTHANC_PUBLIC LogLevel StringToLogLevel(const char* level); |
b3f09bc9734b
sharing more code between the loggers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3996
diff
changeset
|
79 |
3995
1f405a3fdeca
reorganizing Logging
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3993
diff
changeset
|
80 // "pluginContext" must be of type "OrthancPluginContext" |
4014
27628b0f6ada
merging logging code for plugins and files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4010
diff
changeset
|
81 ORTHANC_PUBLIC void InitializePluginContext(void* pluginContext); |
27628b0f6ada
merging logging code for plugins and files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4010
diff
changeset
|
82 |
5575
d7eaa568da15
Orthanc::Logging automatically detects whether the Orthanc core supports OrthancPluginLogMessage()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5571
diff
changeset
|
83 ORTHANC_PUBLIC void InitializePluginContext(void* pluginContext, |
d7eaa568da15
Orthanc::Logging automatically detects whether the Orthanc core supports OrthancPluginLogMessage()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5571
diff
changeset
|
84 const std::string& pluginName); |
5561
0b18690c1935
SDK: added OrthancPluginLogMessage to display plugin name + file and line from plugin
Alain Mazy <am@orthanc.team>
parents:
5485
diff
changeset
|
85 |
3993 | 86 ORTHANC_PUBLIC void Initialize(); |
1485 | 87 |
3993 | 88 ORTHANC_PUBLIC void Finalize(); |
1485 | 89 |
3993 | 90 ORTHANC_PUBLIC void Reset(); |
2015
bcc575732aef
New option "--logfile" to output the Orthanc log to the given file
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2014
diff
changeset
|
91 |
3993 | 92 ORTHANC_PUBLIC void Flush(); |
2015
bcc575732aef
New option "--logfile" to output the Orthanc log to the given file
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2014
diff
changeset
|
93 |
5450
9ffd6d18daf3
log lines now contain the thread name
Alain Mazy <am@osimis.io>
parents:
5357
diff
changeset
|
94 ORTHANC_PUBLIC void SetCurrentThreadName(const std::string& name); |
9ffd6d18daf3
log lines now contain the thread name
Alain Mazy <am@osimis.io>
parents:
5357
diff
changeset
|
95 |
9ffd6d18daf3
log lines now contain the thread name
Alain Mazy <am@osimis.io>
parents:
5357
diff
changeset
|
96 ORTHANC_PUBLIC bool HasCurrentThreadName(); |
9ffd6d18daf3
log lines now contain the thread name
Alain Mazy <am@osimis.io>
parents:
5357
diff
changeset
|
97 |
9ffd6d18daf3
log lines now contain the thread name
Alain Mazy <am@osimis.io>
parents:
5357
diff
changeset
|
98 ORTHANC_PUBLIC void EnableThreadNames(bool enabled); |
9ffd6d18daf3
log lines now contain the thread name
Alain Mazy <am@osimis.io>
parents:
5357
diff
changeset
|
99 |
3993 | 100 ORTHANC_PUBLIC void EnableInfoLevel(bool enabled); |
1485 | 101 |
3993 | 102 ORTHANC_PUBLIC void EnableTraceLevel(bool enabled); |
1489 | 103 |
3993 | 104 ORTHANC_PUBLIC bool IsTraceLevelEnabled(); |
3359
815b81142ff7
Enable custom logging functions to redirect to emscripten specific logging calls
Benjamin Golinvaux <bgo@osimis.io>
parents:
3353
diff
changeset
|
105 |
3993 | 106 ORTHANC_PUBLIC bool IsInfoLevelEnabled(); |
3353
54cdad5a7228
Added a public function that will use emscripten-specific logging functions when using its SDK + scaffolding work. Build and UT OK on msvc15 x64. Not actually tested under *nix or emscripten yet
Benjamin Golinvaux <bgo@osimis.io>
parents:
3060
diff
changeset
|
107 |
4270
251a8b07fa37
logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4269
diff
changeset
|
108 ORTHANC_PUBLIC void SetCategoryEnabled(LogLevel level, |
251a8b07fa37
logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4269
diff
changeset
|
109 LogCategory category, |
251a8b07fa37
logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4269
diff
changeset
|
110 bool enabled); |
251a8b07fa37
logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4269
diff
changeset
|
111 |
251a8b07fa37
logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4269
diff
changeset
|
112 ORTHANC_PUBLIC bool IsCategoryEnabled(LogLevel level, |
251a8b07fa37
logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4269
diff
changeset
|
113 LogCategory category); |
251a8b07fa37
logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4269
diff
changeset
|
114 |
4273
0034f855c023
tuning log categories from command-line, and binary compat with orthanc framework 1.7.2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4272
diff
changeset
|
115 ORTHANC_PUBLIC bool LookupCategory(LogCategory& target, |
0034f855c023
tuning log categories from command-line, and binary compat with orthanc framework 1.7.2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4272
diff
changeset
|
116 const std::string& category); |
0034f855c023
tuning log categories from command-line, and binary compat with orthanc framework 1.7.2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4272
diff
changeset
|
117 |
4275
d7a50b7b8466
Dynamically access and/or change the verbosity of logging categories with the REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4273
diff
changeset
|
118 ORTHANC_PUBLIC unsigned int GetCategoriesCount(); |
4273
0034f855c023
tuning log categories from command-line, and binary compat with orthanc framework 1.7.2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4272
diff
changeset
|
119 |
4275
d7a50b7b8466
Dynamically access and/or change the verbosity of logging categories with the REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4273
diff
changeset
|
120 ORTHANC_PUBLIC const char* GetCategoryName(unsigned int i); |
d7a50b7b8466
Dynamically access and/or change the verbosity of logging categories with the REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4273
diff
changeset
|
121 |
d7a50b7b8466
Dynamically access and/or change the verbosity of logging categories with the REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4273
diff
changeset
|
122 ORTHANC_PUBLIC const char* GetCategoryName(LogCategory category); |
4270
251a8b07fa37
logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4269
diff
changeset
|
123 |
3993 | 124 ORTHANC_PUBLIC void SetTargetFile(const std::string& path); |
2015
bcc575732aef
New option "--logfile" to output the Orthanc log to the given file
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2014
diff
changeset
|
125 |
3993 | 126 ORTHANC_PUBLIC void SetTargetFolder(const std::string& path); |
1489 | 127 |
4313
91554aecff9a
removed a friend method for better abi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4294
diff
changeset
|
128 struct ORTHANC_LOCAL NullStream : public std::ostream |
1495
fbe40117eb21
improve the performance of the internal logger
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1491
diff
changeset
|
129 { |
fbe40117eb21
improve the performance of the internal logger
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1491
diff
changeset
|
130 NullStream() : |
fbe40117eb21
improve the performance of the internal logger
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1491
diff
changeset
|
131 std::ios(0), |
fbe40117eb21
improve the performance of the internal logger
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1491
diff
changeset
|
132 std::ostream(0) |
fbe40117eb21
improve the performance of the internal logger
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1491
diff
changeset
|
133 { |
fbe40117eb21
improve the performance of the internal logger
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1491
diff
changeset
|
134 } |
1551
0dba274074eb
standalone logging
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1507
diff
changeset
|
135 |
2504 | 136 template <typename T> |
137 std::ostream& operator<< (const T& message) | |
2073
1d7a640c1dda
fix build issues with Visual Studio 2015
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2015
diff
changeset
|
138 { |
1d7a640c1dda
fix build issues with Visual Studio 2015
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2015
diff
changeset
|
139 return *this; |
1d7a640c1dda
fix build issues with Visual Studio 2015
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2015
diff
changeset
|
140 } |
1495
fbe40117eb21
improve the performance of the internal logger
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1491
diff
changeset
|
141 }; |
1551
0dba274074eb
standalone logging
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1507
diff
changeset
|
142 } |
0dba274074eb
standalone logging
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1507
diff
changeset
|
143 } |
1489 | 144 |
3998
b3f09bc9734b
sharing more code between the loggers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3996
diff
changeset
|
145 |
4268
0ae2ca210077
new macro TLOG() to replace VLOG() for trace logs with a category
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4119
diff
changeset
|
146 |
0ae2ca210077
new macro TLOG() to replace VLOG() for trace logs with a category
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4119
diff
changeset
|
147 /** |
4269
c7bd2f21ccc3
new macro CLOG, and sharing more code between logging engines
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4268
diff
changeset
|
148 * NB: |
c7bd2f21ccc3
new macro CLOG, and sharing more code between logging engines
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4268
diff
changeset
|
149 * - The "VLOG(unused)" macro is for backward compatibility with |
c7bd2f21ccc3
new macro CLOG, and sharing more code between logging engines
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4268
diff
changeset
|
150 * Orthanc <= 1.8.0. |
c7bd2f21ccc3
new macro CLOG, and sharing more code between logging engines
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4268
diff
changeset
|
151 * - The "CLOG()" macro stands for "category log" (new in Orthanc 1.8.1) |
4268
0ae2ca210077
new macro TLOG() to replace VLOG() for trace logs with a category
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4119
diff
changeset
|
152 **/ |
0ae2ca210077
new macro TLOG() to replace VLOG() for trace logs with a category
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4119
diff
changeset
|
153 |
4269
c7bd2f21ccc3
new macro CLOG, and sharing more code between logging engines
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4268
diff
changeset
|
154 #if defined(LOG) |
c7bd2f21ccc3
new macro CLOG, and sharing more code between logging engines
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4268
diff
changeset
|
155 # error The macro LOG cannot be defined beforehand |
c7bd2f21ccc3
new macro CLOG, and sharing more code between logging engines
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4268
diff
changeset
|
156 #endif |
c7bd2f21ccc3
new macro CLOG, and sharing more code between logging engines
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4268
diff
changeset
|
157 |
c7bd2f21ccc3
new macro CLOG, and sharing more code between logging engines
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4268
diff
changeset
|
158 #if defined(VLOG) |
c7bd2f21ccc3
new macro CLOG, and sharing more code between logging engines
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4268
diff
changeset
|
159 # error The macro VLOG cannot be defined beforehand |
c7bd2f21ccc3
new macro CLOG, and sharing more code between logging engines
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4268
diff
changeset
|
160 #endif |
c7bd2f21ccc3
new macro CLOG, and sharing more code between logging engines
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4268
diff
changeset
|
161 |
c7bd2f21ccc3
new macro CLOG, and sharing more code between logging engines
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4268
diff
changeset
|
162 #if defined(CLOG) |
c7bd2f21ccc3
new macro CLOG, and sharing more code between logging engines
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4268
diff
changeset
|
163 # error The macro CLOG cannot be defined beforehand |
c7bd2f21ccc3
new macro CLOG, and sharing more code between logging engines
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4268
diff
changeset
|
164 #endif |
c7bd2f21ccc3
new macro CLOG, and sharing more code between logging engines
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4268
diff
changeset
|
165 |
1551
0dba274074eb
standalone logging
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1507
diff
changeset
|
166 #if ORTHANC_ENABLE_LOGGING != 1 |
4269
c7bd2f21ccc3
new macro CLOG, and sharing more code between logging engines
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4268
diff
changeset
|
167 # define LOG(level) ::Orthanc::Logging::NullStream() |
c7bd2f21ccc3
new macro CLOG, and sharing more code between logging engines
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4268
diff
changeset
|
168 # define VLOG(unused) ::Orthanc::Logging::NullStream() |
c7bd2f21ccc3
new macro CLOG, and sharing more code between logging engines
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4268
diff
changeset
|
169 # define CLOG(level, category) ::Orthanc::Logging::NullStream() |
5561
0b18690c1935
SDK: added OrthancPluginLogMessage to display plugin name + file and line from plugin
Alain Mazy <am@orthanc.team>
parents:
5485
diff
changeset
|
170 # define LOG_FROM_PLUGIN(level, category, pluginName, file, line) ::Orthanc::Logging::NullStream() |
4017
c783f4f29390
log using emscripten
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4014
diff
changeset
|
171 #else /* ORTHANC_ENABLE_LOGGING == 1 */ |
5357
fddb5d8d0021
Prevent the leak of the full path of the source files in the binaries
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5185
diff
changeset
|
172 |
fddb5d8d0021
Prevent the leak of the full path of the source files in the binaries
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5185
diff
changeset
|
173 #if !defined(__ORTHANC_FILE__) |
fddb5d8d0021
Prevent the leak of the full path of the source files in the binaries
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5185
diff
changeset
|
174 # if defined(_MSC_VER) |
fddb5d8d0021
Prevent the leak of the full path of the source files in the binaries
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5185
diff
changeset
|
175 # pragma message("Warning: Macro __ORTHANC_FILE__ is not defined, this will leak the full path of the source files in the binaries") |
fddb5d8d0021
Prevent the leak of the full path of the source files in the binaries
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5185
diff
changeset
|
176 # else |
fddb5d8d0021
Prevent the leak of the full path of the source files in the binaries
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5185
diff
changeset
|
177 # warning Warning: Macro __ORTHANC_FILE__ is not defined, this will leak the full path of the source files in the binaries |
fddb5d8d0021
Prevent the leak of the full path of the source files in the binaries
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5185
diff
changeset
|
178 # endif |
fddb5d8d0021
Prevent the leak of the full path of the source files in the binaries
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5185
diff
changeset
|
179 # define __ORTHANC_FILE__ __FILE__ |
fddb5d8d0021
Prevent the leak of the full path of the source files in the binaries
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5185
diff
changeset
|
180 #endif |
fddb5d8d0021
Prevent the leak of the full path of the source files in the binaries
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5185
diff
changeset
|
181 |
fddb5d8d0021
Prevent the leak of the full path of the source files in the binaries
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5185
diff
changeset
|
182 # define LOG(level) ::Orthanc::Logging::InternalLogger \ |
fddb5d8d0021
Prevent the leak of the full path of the source files in the binaries
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5185
diff
changeset
|
183 (::Orthanc::Logging::LogLevel_ ## level, \ |
5571
addccb1590d2
simplifying Orthanc::Logging
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5561
diff
changeset
|
184 ::Orthanc::Logging::LogCategory_GENERIC, NULL /* no plugin */, \ |
addccb1590d2
simplifying Orthanc::Logging
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5561
diff
changeset
|
185 __ORTHANC_FILE__, __LINE__) |
addccb1590d2
simplifying Orthanc::Logging
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5561
diff
changeset
|
186 |
5357
fddb5d8d0021
Prevent the leak of the full path of the source files in the binaries
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5185
diff
changeset
|
187 # define VLOG(unused) ::Orthanc::Logging::InternalLogger \ |
fddb5d8d0021
Prevent the leak of the full path of the source files in the binaries
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5185
diff
changeset
|
188 (::Orthanc::Logging::LogLevel_TRACE, \ |
5571
addccb1590d2
simplifying Orthanc::Logging
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5561
diff
changeset
|
189 ::Orthanc::Logging::LogCategory_GENERIC, NULL /* no plugin */, \ |
addccb1590d2
simplifying Orthanc::Logging
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5561
diff
changeset
|
190 __ORTHANC_FILE__, __LINE__) |
addccb1590d2
simplifying Orthanc::Logging
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5561
diff
changeset
|
191 |
4269
c7bd2f21ccc3
new macro CLOG, and sharing more code between logging engines
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4268
diff
changeset
|
192 # define CLOG(level, category) ::Orthanc::Logging::InternalLogger \ |
c7bd2f21ccc3
new macro CLOG, and sharing more code between logging engines
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4268
diff
changeset
|
193 (::Orthanc::Logging::LogLevel_ ## level, \ |
5571
addccb1590d2
simplifying Orthanc::Logging
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5561
diff
changeset
|
194 ::Orthanc::Logging::LogCategory_ ## category, NULL /* no plugin */, \ |
addccb1590d2
simplifying Orthanc::Logging
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5561
diff
changeset
|
195 __ORTHANC_FILE__, __LINE__) |
addccb1590d2
simplifying Orthanc::Logging
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5561
diff
changeset
|
196 |
addccb1590d2
simplifying Orthanc::Logging
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5561
diff
changeset
|
197 # define LOG_FROM_PLUGIN(level, category, pluginName, file, line) \ |
addccb1590d2
simplifying Orthanc::Logging
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5561
diff
changeset
|
198 ::Orthanc::Logging::InternalLogger(level, category, pluginName, file, line) |
addccb1590d2
simplifying Orthanc::Logging
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5561
diff
changeset
|
199 |
4017
c783f4f29390
log using emscripten
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4014
diff
changeset
|
200 #endif |
4014
27628b0f6ada
merging logging code for plugins and files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4010
diff
changeset
|
201 |
4017
c783f4f29390
log using emscripten
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4014
diff
changeset
|
202 |
c783f4f29390
log using emscripten
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4014
diff
changeset
|
203 |
c783f4f29390
log using emscripten
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4014
diff
changeset
|
204 #if (ORTHANC_ENABLE_LOGGING == 1 && \ |
c783f4f29390
log using emscripten
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4014
diff
changeset
|
205 ORTHANC_ENABLE_LOGGING_STDIO == 1) |
c783f4f29390
log using emscripten
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4014
diff
changeset
|
206 // This is notably for WebAssembly |
c783f4f29390
log using emscripten
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4014
diff
changeset
|
207 |
c783f4f29390
log using emscripten
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4014
diff
changeset
|
208 #include <boost/lexical_cast.hpp> |
c783f4f29390
log using emscripten
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4014
diff
changeset
|
209 #include <boost/noncopyable.hpp> |
c783f4f29390
log using emscripten
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4014
diff
changeset
|
210 #include <sstream> |
4014
27628b0f6ada
merging logging code for plugins and files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4010
diff
changeset
|
211 |
4017
c783f4f29390
log using emscripten
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4014
diff
changeset
|
212 namespace Orthanc |
c783f4f29390
log using emscripten
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4014
diff
changeset
|
213 { |
c783f4f29390
log using emscripten
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4014
diff
changeset
|
214 namespace Logging |
c783f4f29390
log using emscripten
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4014
diff
changeset
|
215 { |
c783f4f29390
log using emscripten
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4014
diff
changeset
|
216 class ORTHANC_PUBLIC InternalLogger : public boost::noncopyable |
c783f4f29390
log using emscripten
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4014
diff
changeset
|
217 { |
c783f4f29390
log using emscripten
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4014
diff
changeset
|
218 private: |
c783f4f29390
log using emscripten
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4014
diff
changeset
|
219 LogLevel level_; |
4269
c7bd2f21ccc3
new macro CLOG, and sharing more code between logging engines
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4268
diff
changeset
|
220 LogCategory category_; |
4017
c783f4f29390
log using emscripten
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4014
diff
changeset
|
221 std::stringstream messageStream_; |
c783f4f29390
log using emscripten
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4014
diff
changeset
|
222 |
c783f4f29390
log using emscripten
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4014
diff
changeset
|
223 public: |
c783f4f29390
log using emscripten
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4014
diff
changeset
|
224 InternalLogger(LogLevel level, |
4269
c7bd2f21ccc3
new macro CLOG, and sharing more code between logging engines
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4268
diff
changeset
|
225 LogCategory category, |
4017
c783f4f29390
log using emscripten
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4014
diff
changeset
|
226 const char* file /* ignored */, |
c783f4f29390
log using emscripten
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4014
diff
changeset
|
227 int line /* ignored */) : |
4268
0ae2ca210077
new macro TLOG() to replace VLOG() for trace logs with a category
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4119
diff
changeset
|
228 level_(level), |
0ae2ca210077
new macro TLOG() to replace VLOG() for trace logs with a category
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4119
diff
changeset
|
229 category_(category) |
4017
c783f4f29390
log using emscripten
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4014
diff
changeset
|
230 { |
c783f4f29390
log using emscripten
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4014
diff
changeset
|
231 } |
c783f4f29390
log using emscripten
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4014
diff
changeset
|
232 |
4273
0034f855c023
tuning log categories from command-line, and binary compat with orthanc framework 1.7.2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4272
diff
changeset
|
233 // For backward binary compatibility with Orthanc Framework <= 1.8.0 |
0034f855c023
tuning log categories from command-line, and binary compat with orthanc framework 1.7.2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4272
diff
changeset
|
234 InternalLogger(LogLevel level, |
0034f855c023
tuning log categories from command-line, and binary compat with orthanc framework 1.7.2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4272
diff
changeset
|
235 const char* file /* ignored */, |
0034f855c023
tuning log categories from command-line, and binary compat with orthanc framework 1.7.2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4272
diff
changeset
|
236 int line /* ignored */) : |
0034f855c023
tuning log categories from command-line, and binary compat with orthanc framework 1.7.2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4272
diff
changeset
|
237 level_(level), |
0034f855c023
tuning log categories from command-line, and binary compat with orthanc framework 1.7.2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4272
diff
changeset
|
238 category_(LogCategory_GENERIC) |
0034f855c023
tuning log categories from command-line, and binary compat with orthanc framework 1.7.2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4272
diff
changeset
|
239 { |
0034f855c023
tuning log categories from command-line, and binary compat with orthanc framework 1.7.2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4272
diff
changeset
|
240 } |
0034f855c023
tuning log categories from command-line, and binary compat with orthanc framework 1.7.2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4272
diff
changeset
|
241 |
4017
c783f4f29390
log using emscripten
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4014
diff
changeset
|
242 ~InternalLogger(); |
c783f4f29390
log using emscripten
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4014
diff
changeset
|
243 |
c783f4f29390
log using emscripten
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4014
diff
changeset
|
244 template <typename T> |
c783f4f29390
log using emscripten
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4014
diff
changeset
|
245 std::ostream& operator<< (const T& message) |
c783f4f29390
log using emscripten
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4014
diff
changeset
|
246 { |
c783f4f29390
log using emscripten
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4014
diff
changeset
|
247 return messageStream_ << boost::lexical_cast<std::string>(message); |
c783f4f29390
log using emscripten
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4014
diff
changeset
|
248 } |
c783f4f29390
log using emscripten
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4014
diff
changeset
|
249 }; |
c783f4f29390
log using emscripten
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4014
diff
changeset
|
250 } |
c783f4f29390
log using emscripten
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4014
diff
changeset
|
251 } |
c783f4f29390
log using emscripten
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4014
diff
changeset
|
252 |
c783f4f29390
log using emscripten
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4014
diff
changeset
|
253 #endif |
c783f4f29390
log using emscripten
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4014
diff
changeset
|
254 |
c783f4f29390
log using emscripten
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4014
diff
changeset
|
255 |
c783f4f29390
log using emscripten
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4014
diff
changeset
|
256 |
c783f4f29390
log using emscripten
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4014
diff
changeset
|
257 #if (ORTHANC_ENABLE_LOGGING == 1 && \ |
c783f4f29390
log using emscripten
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4014
diff
changeset
|
258 ORTHANC_ENABLE_LOGGING_STDIO == 0) |
2243
2dbfdafc2512
Logger compatible with the Orthanc plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2137
diff
changeset
|
259 |
4014
27628b0f6ada
merging logging code for plugins and files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4010
diff
changeset
|
260 #include <boost/lexical_cast.hpp> |
3998
b3f09bc9734b
sharing more code between the loggers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3996
diff
changeset
|
261 #include <boost/noncopyable.hpp> |
4014
27628b0f6ada
merging logging code for plugins and files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4010
diff
changeset
|
262 #include <boost/thread/mutex.hpp> |
27628b0f6ada
merging logging code for plugins and files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4010
diff
changeset
|
263 #include <sstream> |
2243
2dbfdafc2512
Logger compatible with the Orthanc plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2137
diff
changeset
|
264 |
2dbfdafc2512
Logger compatible with the Orthanc plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2137
diff
changeset
|
265 namespace Orthanc |
2dbfdafc2512
Logger compatible with the Orthanc plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2137
diff
changeset
|
266 { |
2dbfdafc2512
Logger compatible with the Orthanc plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2137
diff
changeset
|
267 namespace Logging |
2dbfdafc2512
Logger compatible with the Orthanc plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2137
diff
changeset
|
268 { |
3992
f9863630ec7f
working on the shared library for Orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3640
diff
changeset
|
269 class ORTHANC_PUBLIC InternalLogger : public boost::noncopyable |
2243
2dbfdafc2512
Logger compatible with the Orthanc plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2137
diff
changeset
|
270 { |
2dbfdafc2512
Logger compatible with the Orthanc plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2137
diff
changeset
|
271 private: |
4014
27628b0f6ada
merging logging code for plugins and files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4010
diff
changeset
|
272 boost::mutex::scoped_lock lock_; |
27628b0f6ada
merging logging code for plugins and files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4010
diff
changeset
|
273 LogLevel level_; |
27628b0f6ada
merging logging code for plugins and files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4010
diff
changeset
|
274 std::unique_ptr<std::stringstream> pluginStream_; |
27628b0f6ada
merging logging code for plugins and files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4010
diff
changeset
|
275 std::ostream* stream_; |
5561
0b18690c1935
SDK: added OrthancPluginLogMessage to display plugin name + file and line from plugin
Alain Mazy <am@orthanc.team>
parents:
5485
diff
changeset
|
276 LogCategory category_; |
0b18690c1935
SDK: added OrthancPluginLogMessage to display plugin name + file and line from plugin
Alain Mazy <am@orthanc.team>
parents:
5485
diff
changeset
|
277 const char* file_; |
0b18690c1935
SDK: added OrthancPluginLogMessage to display plugin name + file and line from plugin
Alain Mazy <am@orthanc.team>
parents:
5485
diff
changeset
|
278 uint32_t line_; |
1489 | 279 |
280 public: | |
3998
b3f09bc9734b
sharing more code between the loggers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3996
diff
changeset
|
281 InternalLogger(LogLevel level, |
4269
c7bd2f21ccc3
new macro CLOG, and sharing more code between logging engines
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4268
diff
changeset
|
282 LogCategory category, |
5561
0b18690c1935
SDK: added OrthancPluginLogMessage to display plugin name + file and line from plugin
Alain Mazy <am@orthanc.team>
parents:
5485
diff
changeset
|
283 const char* pluginName, |
0b18690c1935
SDK: added OrthancPluginLogMessage to display plugin name + file and line from plugin
Alain Mazy <am@orthanc.team>
parents:
5485
diff
changeset
|
284 const char* file, |
0b18690c1935
SDK: added OrthancPluginLogMessage to display plugin name + file and line from plugin
Alain Mazy <am@orthanc.team>
parents:
5485
diff
changeset
|
285 int line); |
0b18690c1935
SDK: added OrthancPluginLogMessage to display plugin name + file and line from plugin
Alain Mazy <am@orthanc.team>
parents:
5485
diff
changeset
|
286 |
1507 | 287 ~InternalLogger(); |
1495
fbe40117eb21
improve the performance of the internal logger
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1491
diff
changeset
|
288 |
2504 | 289 template <typename T> |
3993 | 290 std::ostream& operator<< (const T& message) |
1489 | 291 { |
2504 | 292 return (*stream_) << boost::lexical_cast<std::string>(message); |
2134
ddc75c6c712d
Avoid hard crash if not enough memory
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2073
diff
changeset
|
293 } |
1489 | 294 }; |
3353
54cdad5a7228
Added a public function that will use emscripten-specific logging functions when using its SDK + scaffolding work. Build and UT OK on msvc15 x64. Not actually tested under *nix or emscripten yet
Benjamin Golinvaux <bgo@osimis.io>
parents:
3060
diff
changeset
|
295 |
54cdad5a7228
Added a public function that will use emscripten-specific logging functions when using its SDK + scaffolding work. Build and UT OK on msvc15 x64. Not actually tested under *nix or emscripten yet
Benjamin Golinvaux <bgo@osimis.io>
parents:
3060
diff
changeset
|
296 /** |
4004
9b5ace33a00d
cleaning SetErrorWarnInfoLoggingStreams()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4003
diff
changeset
|
297 * Set custom logging streams for the error, warning and info |
9b5ace33a00d
cleaning SetErrorWarnInfoLoggingStreams()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4003
diff
changeset
|
298 * logs. This function may not be called if a log file or folder |
9b5ace33a00d
cleaning SetErrorWarnInfoLoggingStreams()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4003
diff
changeset
|
299 * has been set beforehand. All three references must be valid. |
9b5ace33a00d
cleaning SetErrorWarnInfoLoggingStreams()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4003
diff
changeset
|
300 * |
9b5ace33a00d
cleaning SetErrorWarnInfoLoggingStreams()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4003
diff
changeset
|
301 * Please ensure the supplied streams remain alive and valid as |
9b5ace33a00d
cleaning SetErrorWarnInfoLoggingStreams()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4003
diff
changeset
|
302 * long as logging calls are performed. In order to prevent |
9b5ace33a00d
cleaning SetErrorWarnInfoLoggingStreams()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4003
diff
changeset
|
303 * dangling pointer usage, it is mandatory to call |
9b5ace33a00d
cleaning SetErrorWarnInfoLoggingStreams()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4003
diff
changeset
|
304 * Orthanc::Logging::Reset() before the stream objects are |
9b5ace33a00d
cleaning SetErrorWarnInfoLoggingStreams()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4003
diff
changeset
|
305 * destroyed and the references become invalid. |
9b5ace33a00d
cleaning SetErrorWarnInfoLoggingStreams()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4003
diff
changeset
|
306 * |
4014
27628b0f6ada
merging logging code for plugins and files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4010
diff
changeset
|
307 * This function must only be used by unit tests. It is ignored if |
27628b0f6ada
merging logging code for plugins and files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4010
diff
changeset
|
308 * InitializePluginContext() was called. |
4004
9b5ace33a00d
cleaning SetErrorWarnInfoLoggingStreams()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4003
diff
changeset
|
309 **/ |
9b5ace33a00d
cleaning SetErrorWarnInfoLoggingStreams()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4003
diff
changeset
|
310 ORTHANC_PUBLIC void SetErrorWarnInfoLoggingStreams(std::ostream& errorStream, |
9b5ace33a00d
cleaning SetErrorWarnInfoLoggingStreams()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4003
diff
changeset
|
311 std::ostream& warningStream, |
9b5ace33a00d
cleaning SetErrorWarnInfoLoggingStreams()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4003
diff
changeset
|
312 std::ostream& infoStream); |
1485 | 313 } |
314 } | |
1488 | 315 |
3998
b3f09bc9734b
sharing more code between the loggers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3996
diff
changeset
|
316 #endif |