Mercurial > hg > orthanc
annotate Core/Logging.cpp @ 3551:173c7f363d8f
DicomMap::RemoveBinaryTags
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Sat, 26 Oct 2019 15:59:59 +0200 |
parents | d2b9981017c4 |
children | 19966d299685 |
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 |
3060
4e43e67f8ecf
preparing for 2019
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2836
diff
changeset
|
5 * Copyright (C) 2017-2019 Osimis S.A., Belgium |
1485 | 6 * |
7 * This program is free software: you can redistribute it and/or | |
8 * modify it under the terms of the GNU General Public License as | |
9 * published by the Free Software Foundation, either version 3 of the | |
10 * License, or (at your option) any later version. | |
11 * | |
12 * In addition, as a special exception, the copyright holders of this | |
13 * program give permission to link the code of its release with the | |
14 * OpenSSL project's "OpenSSL" library (or with modified versions of it | |
15 * that use the same license as the "OpenSSL" library), and distribute | |
16 * the linked executables. You must obey the GNU General Public License | |
17 * in all respects for all of the code used other than "OpenSSL". If you | |
18 * modify file(s) with this exception, you may extend this exception to | |
19 * your version of the file(s), but you are not obligated to do so. If | |
20 * you do not wish to do so, delete this exception statement from your | |
21 * version. If you delete this exception statement from all source files | |
22 * in the program, then also delete it here. | |
23 * | |
24 * This program is distributed in the hope that it will be useful, but | |
25 * WITHOUT ANY WARRANTY; without even the implied warranty of | |
26 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
27 * General Public License for more details. | |
28 * | |
29 * You should have received a copy of the GNU General Public License | |
30 * along with this program. If not, see <http://www.gnu.org/licenses/>. | |
31 **/ | |
32 | |
33 | |
34 #include "PrecompiledHeaders.h" | |
35 #include "Logging.h" | |
36 | |
1551
0dba274074eb
standalone logging
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1507
diff
changeset
|
37 #if ORTHANC_ENABLE_LOGGING != 1 |
0dba274074eb
standalone logging
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1507
diff
changeset
|
38 |
0dba274074eb
standalone logging
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1507
diff
changeset
|
39 namespace Orthanc |
0dba274074eb
standalone logging
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1507
diff
changeset
|
40 { |
0dba274074eb
standalone logging
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1507
diff
changeset
|
41 namespace Logging |
0dba274074eb
standalone logging
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1507
diff
changeset
|
42 { |
0dba274074eb
standalone logging
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1507
diff
changeset
|
43 void Initialize() |
0dba274074eb
standalone logging
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1507
diff
changeset
|
44 { |
0dba274074eb
standalone logging
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1507
diff
changeset
|
45 } |
0dba274074eb
standalone logging
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1507
diff
changeset
|
46 |
0dba274074eb
standalone logging
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1507
diff
changeset
|
47 void Finalize() |
0dba274074eb
standalone logging
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1507
diff
changeset
|
48 { |
0dba274074eb
standalone logging
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1507
diff
changeset
|
49 } |
1485 | 50 |
2015
bcc575732aef
New option "--logfile" to output the Orthanc log to the given file
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2014
diff
changeset
|
51 void Reset() |
bcc575732aef
New option "--logfile" to output the Orthanc log to the given file
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2014
diff
changeset
|
52 { |
bcc575732aef
New option "--logfile" to output the Orthanc log to the given file
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2014
diff
changeset
|
53 } |
bcc575732aef
New option "--logfile" to output the Orthanc log to the given file
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2014
diff
changeset
|
54 |
bcc575732aef
New option "--logfile" to output the Orthanc log to the given file
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2014
diff
changeset
|
55 void Flush() |
bcc575732aef
New option "--logfile" to output the Orthanc log to the given file
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2014
diff
changeset
|
56 { |
bcc575732aef
New option "--logfile" to output the Orthanc log to the given file
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2014
diff
changeset
|
57 } |
bcc575732aef
New option "--logfile" to output the Orthanc log to the given file
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2014
diff
changeset
|
58 |
1551
0dba274074eb
standalone logging
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1507
diff
changeset
|
59 void EnableInfoLevel(bool enabled) |
0dba274074eb
standalone logging
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1507
diff
changeset
|
60 { |
0dba274074eb
standalone logging
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1507
diff
changeset
|
61 } |
1489 | 62 |
1551
0dba274074eb
standalone logging
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1507
diff
changeset
|
63 void EnableTraceLevel(bool enabled) |
0dba274074eb
standalone logging
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1507
diff
changeset
|
64 { |
0dba274074eb
standalone logging
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1507
diff
changeset
|
65 } |
3359
815b81142ff7
Enable custom logging functions to redirect to emscripten specific logging calls
Benjamin Golinvaux <bgo@osimis.io>
parents:
3353
diff
changeset
|
66 |
815b81142ff7
Enable custom logging functions to redirect to emscripten specific logging calls
Benjamin Golinvaux <bgo@osimis.io>
parents:
3353
diff
changeset
|
67 bool IsTraceLevelEnabled() |
815b81142ff7
Enable custom logging functions to redirect to emscripten specific logging calls
Benjamin Golinvaux <bgo@osimis.io>
parents:
3353
diff
changeset
|
68 { |
815b81142ff7
Enable custom logging functions to redirect to emscripten specific logging calls
Benjamin Golinvaux <bgo@osimis.io>
parents:
3353
diff
changeset
|
69 return false; |
815b81142ff7
Enable custom logging functions to redirect to emscripten specific logging calls
Benjamin Golinvaux <bgo@osimis.io>
parents:
3353
diff
changeset
|
70 } |
1551
0dba274074eb
standalone logging
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1507
diff
changeset
|
71 |
3359
815b81142ff7
Enable custom logging functions to redirect to emscripten specific logging calls
Benjamin Golinvaux <bgo@osimis.io>
parents:
3353
diff
changeset
|
72 bool IsInfoLevelEnabled() |
815b81142ff7
Enable custom logging functions to redirect to emscripten specific logging calls
Benjamin Golinvaux <bgo@osimis.io>
parents:
3353
diff
changeset
|
73 { |
815b81142ff7
Enable custom logging functions to redirect to emscripten specific logging calls
Benjamin Golinvaux <bgo@osimis.io>
parents:
3353
diff
changeset
|
74 return false; |
815b81142ff7
Enable custom logging functions to redirect to emscripten specific logging calls
Benjamin Golinvaux <bgo@osimis.io>
parents:
3353
diff
changeset
|
75 } |
815b81142ff7
Enable custom logging functions to redirect to emscripten specific logging calls
Benjamin Golinvaux <bgo@osimis.io>
parents:
3353
diff
changeset
|
76 |
2015
bcc575732aef
New option "--logfile" to output the Orthanc log to the given file
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2014
diff
changeset
|
77 void SetTargetFile(const std::string& path) |
bcc575732aef
New option "--logfile" to output the Orthanc log to the given file
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2014
diff
changeset
|
78 { |
bcc575732aef
New option "--logfile" to output the Orthanc log to the given file
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2014
diff
changeset
|
79 } |
bcc575732aef
New option "--logfile" to output the Orthanc log to the given file
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2014
diff
changeset
|
80 |
1551
0dba274074eb
standalone logging
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1507
diff
changeset
|
81 void SetTargetFolder(const std::string& path) |
0dba274074eb
standalone logging
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1507
diff
changeset
|
82 { |
0dba274074eb
standalone logging
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1507
diff
changeset
|
83 } |
0dba274074eb
standalone logging
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1507
diff
changeset
|
84 } |
0dba274074eb
standalone logging
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1507
diff
changeset
|
85 } |
0dba274074eb
standalone logging
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1507
diff
changeset
|
86 |
2243
2dbfdafc2512
Logger compatible with the Orthanc plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2143
diff
changeset
|
87 |
2dbfdafc2512
Logger compatible with the Orthanc plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2143
diff
changeset
|
88 #elif ORTHANC_ENABLE_LOGGING_PLUGIN == 1 |
2dbfdafc2512
Logger compatible with the Orthanc plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2143
diff
changeset
|
89 |
2dbfdafc2512
Logger compatible with the Orthanc plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2143
diff
changeset
|
90 /********************************************************* |
2dbfdafc2512
Logger compatible with the Orthanc plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2143
diff
changeset
|
91 * Logger compatible with the Orthanc plugin SDK |
2dbfdafc2512
Logger compatible with the Orthanc plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2143
diff
changeset
|
92 *********************************************************/ |
2dbfdafc2512
Logger compatible with the Orthanc plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2143
diff
changeset
|
93 |
2dbfdafc2512
Logger compatible with the Orthanc plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2143
diff
changeset
|
94 #include <boost/lexical_cast.hpp> |
3489
e7723a39adf8
Fixed alignment issue in Toolbox::DetectEndianness() + made the internal logger
Benjamin Golinvaux <bgo@osimis.io>
parents:
3477
diff
changeset
|
95 #include <sstream> |
2243
2dbfdafc2512
Logger compatible with the Orthanc plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2143
diff
changeset
|
96 |
2dbfdafc2512
Logger compatible with the Orthanc plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2143
diff
changeset
|
97 namespace Orthanc |
2dbfdafc2512
Logger compatible with the Orthanc plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2143
diff
changeset
|
98 { |
2dbfdafc2512
Logger compatible with the Orthanc plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2143
diff
changeset
|
99 namespace Logging |
2dbfdafc2512
Logger compatible with the Orthanc plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2143
diff
changeset
|
100 { |
2dbfdafc2512
Logger compatible with the Orthanc plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2143
diff
changeset
|
101 static OrthancPluginContext* context_ = NULL; |
2dbfdafc2512
Logger compatible with the Orthanc plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2143
diff
changeset
|
102 |
2dbfdafc2512
Logger compatible with the Orthanc plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2143
diff
changeset
|
103 void Initialize(OrthancPluginContext* context) |
2dbfdafc2512
Logger compatible with the Orthanc plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2143
diff
changeset
|
104 { |
2253 | 105 context_ = context; |
2243
2dbfdafc2512
Logger compatible with the Orthanc plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2143
diff
changeset
|
106 } |
2dbfdafc2512
Logger compatible with the Orthanc plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2143
diff
changeset
|
107 |
2505 | 108 InternalLogger::InternalLogger(InternalLevel level, |
2243
2dbfdafc2512
Logger compatible with the Orthanc plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2143
diff
changeset
|
109 const char* file /* ignored */, |
2dbfdafc2512
Logger compatible with the Orthanc plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2143
diff
changeset
|
110 int line /* ignored */) : |
2dbfdafc2512
Logger compatible with the Orthanc plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2143
diff
changeset
|
111 level_(level) |
2dbfdafc2512
Logger compatible with the Orthanc plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2143
diff
changeset
|
112 { |
2dbfdafc2512
Logger compatible with the Orthanc plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2143
diff
changeset
|
113 } |
2dbfdafc2512
Logger compatible with the Orthanc plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2143
diff
changeset
|
114 |
2dbfdafc2512
Logger compatible with the Orthanc plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2143
diff
changeset
|
115 InternalLogger::~InternalLogger() |
2dbfdafc2512
Logger compatible with the Orthanc plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2143
diff
changeset
|
116 { |
3489
e7723a39adf8
Fixed alignment issue in Toolbox::DetectEndianness() + made the internal logger
Benjamin Golinvaux <bgo@osimis.io>
parents:
3477
diff
changeset
|
117 std::string message = messageStream_.str(); |
2243
2dbfdafc2512
Logger compatible with the Orthanc plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2143
diff
changeset
|
118 if (context_ != NULL) |
2dbfdafc2512
Logger compatible with the Orthanc plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2143
diff
changeset
|
119 { |
2483
9c54c40eaf25
logging primitives for WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
120 switch (level_) |
2243
2dbfdafc2512
Logger compatible with the Orthanc plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2143
diff
changeset
|
121 { |
2505 | 122 case InternalLevel_ERROR: |
3489
e7723a39adf8
Fixed alignment issue in Toolbox::DetectEndianness() + made the internal logger
Benjamin Golinvaux <bgo@osimis.io>
parents:
3477
diff
changeset
|
123 OrthancPluginLogError(context_, message.c_str()); |
2483
9c54c40eaf25
logging primitives for WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
124 break; |
9c54c40eaf25
logging primitives for WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
125 |
2505 | 126 case InternalLevel_WARNING: |
3489
e7723a39adf8
Fixed alignment issue in Toolbox::DetectEndianness() + made the internal logger
Benjamin Golinvaux <bgo@osimis.io>
parents:
3477
diff
changeset
|
127 OrthancPluginLogWarning(context_, message.c_str()); |
2483
9c54c40eaf25
logging primitives for WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
128 break; |
9c54c40eaf25
logging primitives for WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
129 |
2505 | 130 case InternalLevel_INFO: |
3489
e7723a39adf8
Fixed alignment issue in Toolbox::DetectEndianness() + made the internal logger
Benjamin Golinvaux <bgo@osimis.io>
parents:
3477
diff
changeset
|
131 OrthancPluginLogInfo(context_, message.c_str()); |
2483
9c54c40eaf25
logging primitives for WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
132 break; |
9c54c40eaf25
logging primitives for WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
133 |
2505 | 134 case InternalLevel_TRACE: |
2483
9c54c40eaf25
logging primitives for WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
135 // Not used by plugins |
9c54c40eaf25
logging primitives for WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
136 break; |
9c54c40eaf25
logging primitives for WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
137 |
9c54c40eaf25
logging primitives for WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
138 default: |
9c54c40eaf25
logging primitives for WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
139 { |
9c54c40eaf25
logging primitives for WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
140 std::string s = ("Unknown log level (" + boost::lexical_cast<std::string>(level_) + |
3489
e7723a39adf8
Fixed alignment issue in Toolbox::DetectEndianness() + made the internal logger
Benjamin Golinvaux <bgo@osimis.io>
parents:
3477
diff
changeset
|
141 ") for message: " + message); |
2483
9c54c40eaf25
logging primitives for WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
142 OrthancPluginLogError(context_, s.c_str()); |
9c54c40eaf25
logging primitives for WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
143 break; |
9c54c40eaf25
logging primitives for WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
144 } |
2253 | 145 } |
2243
2dbfdafc2512
Logger compatible with the Orthanc plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2143
diff
changeset
|
146 } |
2dbfdafc2512
Logger compatible with the Orthanc plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2143
diff
changeset
|
147 } |
2dbfdafc2512
Logger compatible with the Orthanc plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2143
diff
changeset
|
148 } |
2dbfdafc2512
Logger compatible with the Orthanc plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2143
diff
changeset
|
149 } |
2dbfdafc2512
Logger compatible with the Orthanc plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2143
diff
changeset
|
150 |
2dbfdafc2512
Logger compatible with the Orthanc plugin SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2143
diff
changeset
|
151 |
2483
9c54c40eaf25
logging primitives for WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
152 #elif ORTHANC_ENABLE_LOGGING_STDIO == 1 |
9c54c40eaf25
logging primitives for WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
153 |
9c54c40eaf25
logging primitives for WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
154 /********************************************************* |
3359
815b81142ff7
Enable custom logging functions to redirect to emscripten specific logging calls
Benjamin Golinvaux <bgo@osimis.io>
parents:
3353
diff
changeset
|
155 * Logger compatible with <stdio.h> OR logger that sends its |
815b81142ff7
Enable custom logging functions to redirect to emscripten specific logging calls
Benjamin Golinvaux <bgo@osimis.io>
parents:
3353
diff
changeset
|
156 * output to the emscripten html5 api (depending on the |
815b81142ff7
Enable custom logging functions to redirect to emscripten specific logging calls
Benjamin Golinvaux <bgo@osimis.io>
parents:
3353
diff
changeset
|
157 * definition of __EMSCRIPTEN__) |
2483
9c54c40eaf25
logging primitives for WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
158 *********************************************************/ |
9c54c40eaf25
logging primitives for WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
159 |
9c54c40eaf25
logging primitives for WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
160 #include <stdio.h> |
9c54c40eaf25
logging primitives for WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
161 #include <boost/lexical_cast.hpp> |
9c54c40eaf25
logging primitives for WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
162 |
3359
815b81142ff7
Enable custom logging functions to redirect to emscripten specific logging calls
Benjamin Golinvaux <bgo@osimis.io>
parents:
3353
diff
changeset
|
163 #ifdef __EMSCRIPTEN__ |
3506
d2b9981017c4
better handling of HTTP security
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3505
diff
changeset
|
164 # include <emscripten/html5.h> |
3359
815b81142ff7
Enable custom logging functions to redirect to emscripten specific logging calls
Benjamin Golinvaux <bgo@osimis.io>
parents:
3353
diff
changeset
|
165 #endif |
815b81142ff7
Enable custom logging functions to redirect to emscripten specific logging calls
Benjamin Golinvaux <bgo@osimis.io>
parents:
3353
diff
changeset
|
166 |
2483
9c54c40eaf25
logging primitives for WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
167 namespace Orthanc |
9c54c40eaf25
logging primitives for WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
168 { |
9c54c40eaf25
logging primitives for WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
169 namespace Logging |
9c54c40eaf25
logging primitives for WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
170 { |
9c54c40eaf25
logging primitives for WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
171 static bool globalVerbose_ = false; |
9c54c40eaf25
logging primitives for WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
172 static bool globalTrace_ = false; |
9c54c40eaf25
logging primitives for WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
173 |
3359
815b81142ff7
Enable custom logging functions to redirect to emscripten specific logging calls
Benjamin Golinvaux <bgo@osimis.io>
parents:
3353
diff
changeset
|
174 #ifdef __EMSCRIPTEN__ |
815b81142ff7
Enable custom logging functions to redirect to emscripten specific logging calls
Benjamin Golinvaux <bgo@osimis.io>
parents:
3353
diff
changeset
|
175 void defaultErrorLogFunc(const char* msg) |
815b81142ff7
Enable custom logging functions to redirect to emscripten specific logging calls
Benjamin Golinvaux <bgo@osimis.io>
parents:
3353
diff
changeset
|
176 { |
815b81142ff7
Enable custom logging functions to redirect to emscripten specific logging calls
Benjamin Golinvaux <bgo@osimis.io>
parents:
3353
diff
changeset
|
177 emscripten_console_error(msg); |
815b81142ff7
Enable custom logging functions to redirect to emscripten specific logging calls
Benjamin Golinvaux <bgo@osimis.io>
parents:
3353
diff
changeset
|
178 } |
815b81142ff7
Enable custom logging functions to redirect to emscripten specific logging calls
Benjamin Golinvaux <bgo@osimis.io>
parents:
3353
diff
changeset
|
179 |
815b81142ff7
Enable custom logging functions to redirect to emscripten specific logging calls
Benjamin Golinvaux <bgo@osimis.io>
parents:
3353
diff
changeset
|
180 void defaultWarningLogFunc(const char* msg) |
815b81142ff7
Enable custom logging functions to redirect to emscripten specific logging calls
Benjamin Golinvaux <bgo@osimis.io>
parents:
3353
diff
changeset
|
181 { |
815b81142ff7
Enable custom logging functions to redirect to emscripten specific logging calls
Benjamin Golinvaux <bgo@osimis.io>
parents:
3353
diff
changeset
|
182 emscripten_console_warn(msg); |
815b81142ff7
Enable custom logging functions to redirect to emscripten specific logging calls
Benjamin Golinvaux <bgo@osimis.io>
parents:
3353
diff
changeset
|
183 } |
815b81142ff7
Enable custom logging functions to redirect to emscripten specific logging calls
Benjamin Golinvaux <bgo@osimis.io>
parents:
3353
diff
changeset
|
184 |
815b81142ff7
Enable custom logging functions to redirect to emscripten specific logging calls
Benjamin Golinvaux <bgo@osimis.io>
parents:
3353
diff
changeset
|
185 void defaultInfoLogFunc(const char* msg) |
815b81142ff7
Enable custom logging functions to redirect to emscripten specific logging calls
Benjamin Golinvaux <bgo@osimis.io>
parents:
3353
diff
changeset
|
186 { |
815b81142ff7
Enable custom logging functions to redirect to emscripten specific logging calls
Benjamin Golinvaux <bgo@osimis.io>
parents:
3353
diff
changeset
|
187 emscripten_console_log(msg); |
815b81142ff7
Enable custom logging functions to redirect to emscripten specific logging calls
Benjamin Golinvaux <bgo@osimis.io>
parents:
3353
diff
changeset
|
188 } |
815b81142ff7
Enable custom logging functions to redirect to emscripten specific logging calls
Benjamin Golinvaux <bgo@osimis.io>
parents:
3353
diff
changeset
|
189 |
815b81142ff7
Enable custom logging functions to redirect to emscripten specific logging calls
Benjamin Golinvaux <bgo@osimis.io>
parents:
3353
diff
changeset
|
190 void defaultTraceLogFunc(const char* msg) |
815b81142ff7
Enable custom logging functions to redirect to emscripten specific logging calls
Benjamin Golinvaux <bgo@osimis.io>
parents:
3353
diff
changeset
|
191 { |
815b81142ff7
Enable custom logging functions to redirect to emscripten specific logging calls
Benjamin Golinvaux <bgo@osimis.io>
parents:
3353
diff
changeset
|
192 emscripten_console_log(msg); |
815b81142ff7
Enable custom logging functions to redirect to emscripten specific logging calls
Benjamin Golinvaux <bgo@osimis.io>
parents:
3353
diff
changeset
|
193 } |
815b81142ff7
Enable custom logging functions to redirect to emscripten specific logging calls
Benjamin Golinvaux <bgo@osimis.io>
parents:
3353
diff
changeset
|
194 #else |
815b81142ff7
Enable custom logging functions to redirect to emscripten specific logging calls
Benjamin Golinvaux <bgo@osimis.io>
parents:
3353
diff
changeset
|
195 // __EMSCRIPTEN__ not #defined |
815b81142ff7
Enable custom logging functions to redirect to emscripten specific logging calls
Benjamin Golinvaux <bgo@osimis.io>
parents:
3353
diff
changeset
|
196 void defaultErrorLogFunc(const char* msg) |
815b81142ff7
Enable custom logging functions to redirect to emscripten specific logging calls
Benjamin Golinvaux <bgo@osimis.io>
parents:
3353
diff
changeset
|
197 { |
815b81142ff7
Enable custom logging functions to redirect to emscripten specific logging calls
Benjamin Golinvaux <bgo@osimis.io>
parents:
3353
diff
changeset
|
198 fprintf(stderr, "E: %s\n", msg); |
815b81142ff7
Enable custom logging functions to redirect to emscripten specific logging calls
Benjamin Golinvaux <bgo@osimis.io>
parents:
3353
diff
changeset
|
199 } |
815b81142ff7
Enable custom logging functions to redirect to emscripten specific logging calls
Benjamin Golinvaux <bgo@osimis.io>
parents:
3353
diff
changeset
|
200 |
815b81142ff7
Enable custom logging functions to redirect to emscripten specific logging calls
Benjamin Golinvaux <bgo@osimis.io>
parents:
3353
diff
changeset
|
201 void defaultWarningLogFunc(const char*) |
815b81142ff7
Enable custom logging functions to redirect to emscripten specific logging calls
Benjamin Golinvaux <bgo@osimis.io>
parents:
3353
diff
changeset
|
202 { |
815b81142ff7
Enable custom logging functions to redirect to emscripten specific logging calls
Benjamin Golinvaux <bgo@osimis.io>
parents:
3353
diff
changeset
|
203 fprintf(stdout, "W: %s\n", msg); |
815b81142ff7
Enable custom logging functions to redirect to emscripten specific logging calls
Benjamin Golinvaux <bgo@osimis.io>
parents:
3353
diff
changeset
|
204 } |
815b81142ff7
Enable custom logging functions to redirect to emscripten specific logging calls
Benjamin Golinvaux <bgo@osimis.io>
parents:
3353
diff
changeset
|
205 |
815b81142ff7
Enable custom logging functions to redirect to emscripten specific logging calls
Benjamin Golinvaux <bgo@osimis.io>
parents:
3353
diff
changeset
|
206 void defaultInfoLogFunc(const char*) |
815b81142ff7
Enable custom logging functions to redirect to emscripten specific logging calls
Benjamin Golinvaux <bgo@osimis.io>
parents:
3353
diff
changeset
|
207 { |
815b81142ff7
Enable custom logging functions to redirect to emscripten specific logging calls
Benjamin Golinvaux <bgo@osimis.io>
parents:
3353
diff
changeset
|
208 fprintf(stdout, "I: %s\n", msg); |
815b81142ff7
Enable custom logging functions to redirect to emscripten specific logging calls
Benjamin Golinvaux <bgo@osimis.io>
parents:
3353
diff
changeset
|
209 } |
815b81142ff7
Enable custom logging functions to redirect to emscripten specific logging calls
Benjamin Golinvaux <bgo@osimis.io>
parents:
3353
diff
changeset
|
210 |
815b81142ff7
Enable custom logging functions to redirect to emscripten specific logging calls
Benjamin Golinvaux <bgo@osimis.io>
parents:
3353
diff
changeset
|
211 void defaultTraceLogFunc(const char*) |
815b81142ff7
Enable custom logging functions to redirect to emscripten specific logging calls
Benjamin Golinvaux <bgo@osimis.io>
parents:
3353
diff
changeset
|
212 { |
815b81142ff7
Enable custom logging functions to redirect to emscripten specific logging calls
Benjamin Golinvaux <bgo@osimis.io>
parents:
3353
diff
changeset
|
213 fprintf(stdout, "T: %s\n", msg); |
815b81142ff7
Enable custom logging functions to redirect to emscripten specific logging calls
Benjamin Golinvaux <bgo@osimis.io>
parents:
3353
diff
changeset
|
214 } |
815b81142ff7
Enable custom logging functions to redirect to emscripten specific logging calls
Benjamin Golinvaux <bgo@osimis.io>
parents:
3353
diff
changeset
|
215 #endif |
815b81142ff7
Enable custom logging functions to redirect to emscripten specific logging calls
Benjamin Golinvaux <bgo@osimis.io>
parents:
3353
diff
changeset
|
216 // __EMSCRIPTEN__ |
815b81142ff7
Enable custom logging functions to redirect to emscripten specific logging calls
Benjamin Golinvaux <bgo@osimis.io>
parents:
3353
diff
changeset
|
217 |
815b81142ff7
Enable custom logging functions to redirect to emscripten specific logging calls
Benjamin Golinvaux <bgo@osimis.io>
parents:
3353
diff
changeset
|
218 static LoggingFunction globalErrorLogFunc = defaultErrorLogFunc; |
815b81142ff7
Enable custom logging functions to redirect to emscripten specific logging calls
Benjamin Golinvaux <bgo@osimis.io>
parents:
3353
diff
changeset
|
219 static LoggingFunction globalWarningLogFunc = defaultWarningLogFunc; |
815b81142ff7
Enable custom logging functions to redirect to emscripten specific logging calls
Benjamin Golinvaux <bgo@osimis.io>
parents:
3353
diff
changeset
|
220 static LoggingFunction globalInfoLogFunc = defaultInfoLogFunc; |
815b81142ff7
Enable custom logging functions to redirect to emscripten specific logging calls
Benjamin Golinvaux <bgo@osimis.io>
parents:
3353
diff
changeset
|
221 static LoggingFunction globalTraceLogFunc = defaultTraceLogFunc; |
815b81142ff7
Enable custom logging functions to redirect to emscripten specific logging calls
Benjamin Golinvaux <bgo@osimis.io>
parents:
3353
diff
changeset
|
222 |
815b81142ff7
Enable custom logging functions to redirect to emscripten specific logging calls
Benjamin Golinvaux <bgo@osimis.io>
parents:
3353
diff
changeset
|
223 void SetErrorWarnInfoTraceLoggingFunctions( |
815b81142ff7
Enable custom logging functions to redirect to emscripten specific logging calls
Benjamin Golinvaux <bgo@osimis.io>
parents:
3353
diff
changeset
|
224 LoggingFunction errorLogFunc, |
815b81142ff7
Enable custom logging functions to redirect to emscripten specific logging calls
Benjamin Golinvaux <bgo@osimis.io>
parents:
3353
diff
changeset
|
225 LoggingFunction warningLogfunc, |
815b81142ff7
Enable custom logging functions to redirect to emscripten specific logging calls
Benjamin Golinvaux <bgo@osimis.io>
parents:
3353
diff
changeset
|
226 LoggingFunction infoLogFunc, |
815b81142ff7
Enable custom logging functions to redirect to emscripten specific logging calls
Benjamin Golinvaux <bgo@osimis.io>
parents:
3353
diff
changeset
|
227 LoggingFunction traceLogFunc) |
815b81142ff7
Enable custom logging functions to redirect to emscripten specific logging calls
Benjamin Golinvaux <bgo@osimis.io>
parents:
3353
diff
changeset
|
228 { |
815b81142ff7
Enable custom logging functions to redirect to emscripten specific logging calls
Benjamin Golinvaux <bgo@osimis.io>
parents:
3353
diff
changeset
|
229 globalErrorLogFunc = errorLogFunc; |
815b81142ff7
Enable custom logging functions to redirect to emscripten specific logging calls
Benjamin Golinvaux <bgo@osimis.io>
parents:
3353
diff
changeset
|
230 globalWarningLogFunc = warningLogfunc; |
815b81142ff7
Enable custom logging functions to redirect to emscripten specific logging calls
Benjamin Golinvaux <bgo@osimis.io>
parents:
3353
diff
changeset
|
231 globalInfoLogFunc = infoLogFunc; |
815b81142ff7
Enable custom logging functions to redirect to emscripten specific logging calls
Benjamin Golinvaux <bgo@osimis.io>
parents:
3353
diff
changeset
|
232 globalTraceLogFunc = traceLogFunc; |
815b81142ff7
Enable custom logging functions to redirect to emscripten specific logging calls
Benjamin Golinvaux <bgo@osimis.io>
parents:
3353
diff
changeset
|
233 } |
815b81142ff7
Enable custom logging functions to redirect to emscripten specific logging calls
Benjamin Golinvaux <bgo@osimis.io>
parents:
3353
diff
changeset
|
234 |
2505 | 235 InternalLogger::InternalLogger(InternalLevel level, |
2483
9c54c40eaf25
logging primitives for WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
236 const char* file /* ignored */, |
9c54c40eaf25
logging primitives for WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
237 int line /* ignored */) : |
9c54c40eaf25
logging primitives for WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
238 level_(level) |
9c54c40eaf25
logging primitives for WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
239 { |
9c54c40eaf25
logging primitives for WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
240 } |
9c54c40eaf25
logging primitives for WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
241 |
9c54c40eaf25
logging primitives for WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
242 InternalLogger::~InternalLogger() |
9c54c40eaf25
logging primitives for WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
243 { |
3489
e7723a39adf8
Fixed alignment issue in Toolbox::DetectEndianness() + made the internal logger
Benjamin Golinvaux <bgo@osimis.io>
parents:
3477
diff
changeset
|
244 std::string message = messageStream_.str(); |
e7723a39adf8
Fixed alignment issue in Toolbox::DetectEndianness() + made the internal logger
Benjamin Golinvaux <bgo@osimis.io>
parents:
3477
diff
changeset
|
245 |
2483
9c54c40eaf25
logging primitives for WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
246 switch (level_) |
9c54c40eaf25
logging primitives for WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
247 { |
2505 | 248 case InternalLevel_ERROR: |
3489
e7723a39adf8
Fixed alignment issue in Toolbox::DetectEndianness() + made the internal logger
Benjamin Golinvaux <bgo@osimis.io>
parents:
3477
diff
changeset
|
249 globalErrorLogFunc(message.c_str()); |
2483
9c54c40eaf25
logging primitives for WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
250 break; |
9c54c40eaf25
logging primitives for WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
251 |
2505 | 252 case InternalLevel_WARNING: |
3489
e7723a39adf8
Fixed alignment issue in Toolbox::DetectEndianness() + made the internal logger
Benjamin Golinvaux <bgo@osimis.io>
parents:
3477
diff
changeset
|
253 globalWarningLogFunc(message.c_str()); |
2483
9c54c40eaf25
logging primitives for WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
254 break; |
9c54c40eaf25
logging primitives for WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
255 |
2505 | 256 case InternalLevel_INFO: |
2483
9c54c40eaf25
logging primitives for WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
257 if (globalVerbose_) |
9c54c40eaf25
logging primitives for WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
258 { |
3489
e7723a39adf8
Fixed alignment issue in Toolbox::DetectEndianness() + made the internal logger
Benjamin Golinvaux <bgo@osimis.io>
parents:
3477
diff
changeset
|
259 globalInfoLogFunc(message.c_str()); |
3359
815b81142ff7
Enable custom logging functions to redirect to emscripten specific logging calls
Benjamin Golinvaux <bgo@osimis.io>
parents:
3353
diff
changeset
|
260 // TODO: stone_console_info(message_.c_str()); |
2483
9c54c40eaf25
logging primitives for WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
261 } |
9c54c40eaf25
logging primitives for WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
262 break; |
9c54c40eaf25
logging primitives for WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
263 |
2505 | 264 case InternalLevel_TRACE: |
2483
9c54c40eaf25
logging primitives for WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
265 if (globalTrace_) |
9c54c40eaf25
logging primitives for WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
266 { |
3489
e7723a39adf8
Fixed alignment issue in Toolbox::DetectEndianness() + made the internal logger
Benjamin Golinvaux <bgo@osimis.io>
parents:
3477
diff
changeset
|
267 globalTraceLogFunc(message.c_str()); |
2483
9c54c40eaf25
logging primitives for WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
268 } |
9c54c40eaf25
logging primitives for WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
269 break; |
9c54c40eaf25
logging primitives for WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
270 |
9c54c40eaf25
logging primitives for WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
271 default: |
3359
815b81142ff7
Enable custom logging functions to redirect to emscripten specific logging calls
Benjamin Golinvaux <bgo@osimis.io>
parents:
3353
diff
changeset
|
272 { |
815b81142ff7
Enable custom logging functions to redirect to emscripten specific logging calls
Benjamin Golinvaux <bgo@osimis.io>
parents:
3353
diff
changeset
|
273 std::stringstream ss; |
3489
e7723a39adf8
Fixed alignment issue in Toolbox::DetectEndianness() + made the internal logger
Benjamin Golinvaux <bgo@osimis.io>
parents:
3477
diff
changeset
|
274 ss << "Unknown log level (" << level_ << ") for message: " << message; |
3505
b2d4dd16dae8
removed C++11 primitive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3489
diff
changeset
|
275 std::string s = ss.str(); |
3359
815b81142ff7
Enable custom logging functions to redirect to emscripten specific logging calls
Benjamin Golinvaux <bgo@osimis.io>
parents:
3353
diff
changeset
|
276 globalErrorLogFunc(s.c_str()); |
815b81142ff7
Enable custom logging functions to redirect to emscripten specific logging calls
Benjamin Golinvaux <bgo@osimis.io>
parents:
3353
diff
changeset
|
277 } |
2483
9c54c40eaf25
logging primitives for WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
278 } |
9c54c40eaf25
logging primitives for WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
279 } |
9c54c40eaf25
logging primitives for WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
280 |
3358
849c651c1381
fix missing symbol
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3060
diff
changeset
|
281 void Initialize() |
849c651c1381
fix missing symbol
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3060
diff
changeset
|
282 { |
849c651c1381
fix missing symbol
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3060
diff
changeset
|
283 } |
849c651c1381
fix missing symbol
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3060
diff
changeset
|
284 |
2483
9c54c40eaf25
logging primitives for WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
285 void EnableInfoLevel(bool enabled) |
9c54c40eaf25
logging primitives for WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
286 { |
9c54c40eaf25
logging primitives for WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
287 globalVerbose_ = enabled; |
9c54c40eaf25
logging primitives for WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
288 } |
9c54c40eaf25
logging primitives for WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
289 |
3359
815b81142ff7
Enable custom logging functions to redirect to emscripten specific logging calls
Benjamin Golinvaux <bgo@osimis.io>
parents:
3353
diff
changeset
|
290 bool IsInfoLevelEnabled() |
815b81142ff7
Enable custom logging functions to redirect to emscripten specific logging calls
Benjamin Golinvaux <bgo@osimis.io>
parents:
3353
diff
changeset
|
291 { |
815b81142ff7
Enable custom logging functions to redirect to emscripten specific logging calls
Benjamin Golinvaux <bgo@osimis.io>
parents:
3353
diff
changeset
|
292 return globalVerbose_; |
815b81142ff7
Enable custom logging functions to redirect to emscripten specific logging calls
Benjamin Golinvaux <bgo@osimis.io>
parents:
3353
diff
changeset
|
293 } |
815b81142ff7
Enable custom logging functions to redirect to emscripten specific logging calls
Benjamin Golinvaux <bgo@osimis.io>
parents:
3353
diff
changeset
|
294 |
2483
9c54c40eaf25
logging primitives for WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
295 void EnableTraceLevel(bool enabled) |
9c54c40eaf25
logging primitives for WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
296 { |
9c54c40eaf25
logging primitives for WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
297 globalTrace_ = enabled; |
9c54c40eaf25
logging primitives for WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
298 } |
3359
815b81142ff7
Enable custom logging functions to redirect to emscripten specific logging calls
Benjamin Golinvaux <bgo@osimis.io>
parents:
3353
diff
changeset
|
299 |
815b81142ff7
Enable custom logging functions to redirect to emscripten specific logging calls
Benjamin Golinvaux <bgo@osimis.io>
parents:
3353
diff
changeset
|
300 bool IsTraceLevelEnabled() |
815b81142ff7
Enable custom logging functions to redirect to emscripten specific logging calls
Benjamin Golinvaux <bgo@osimis.io>
parents:
3353
diff
changeset
|
301 { |
815b81142ff7
Enable custom logging functions to redirect to emscripten specific logging calls
Benjamin Golinvaux <bgo@osimis.io>
parents:
3353
diff
changeset
|
302 return globalTrace_; |
815b81142ff7
Enable custom logging functions to redirect to emscripten specific logging calls
Benjamin Golinvaux <bgo@osimis.io>
parents:
3353
diff
changeset
|
303 } |
815b81142ff7
Enable custom logging functions to redirect to emscripten specific logging calls
Benjamin Golinvaux <bgo@osimis.io>
parents:
3353
diff
changeset
|
304 |
2483
9c54c40eaf25
logging primitives for WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
305 } |
9c54c40eaf25
logging primitives for WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
306 } |
9c54c40eaf25
logging primitives for WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
307 |
9c54c40eaf25
logging primitives for WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
308 |
9c54c40eaf25
logging primitives for WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
309 #else /* ORTHANC_ENABLE_LOGGING_PLUGIN == 0 && |
9c54c40eaf25
logging primitives for WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
310 ORTHANC_ENABLE_LOGGING_STDIO == 0 && |
9c54c40eaf25
logging primitives for WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
311 ORTHANC_ENABLE_LOGGING == 1 */ |
1489 | 312 |
313 /********************************************************* | |
2014
e39a2657f1c6
Dropped support of Google Log
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1900
diff
changeset
|
314 * Internal logger of Orthanc, that mimics some |
e39a2657f1c6
Dropped support of Google Log
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1900
diff
changeset
|
315 * behavior from Google Log. |
1489 | 316 *********************************************************/ |
317 | |
318 #include "OrthancException.h" | |
1495
fbe40117eb21
improve the performance of the internal logger
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1494
diff
changeset
|
319 #include "Enumerations.h" |
1490
596927722403
support of --logdir by the internal logger
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1489
diff
changeset
|
320 #include "Toolbox.h" |
2483
9c54c40eaf25
logging primitives for WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
321 |
9c54c40eaf25
logging primitives for WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
322 #if ORTHANC_SANDBOXED == 1 |
9c54c40eaf25
logging primitives for WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
323 # include <stdio.h> |
9c54c40eaf25
logging primitives for WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
324 #else |
9c54c40eaf25
logging primitives for WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
325 # include "SystemToolbox.h" |
9c54c40eaf25
logging primitives for WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
326 #endif |
1489 | 327 |
1490
596927722403
support of --logdir by the internal logger
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1489
diff
changeset
|
328 #include <fstream> |
1489 | 329 #include <boost/filesystem.hpp> |
330 #include <boost/thread.hpp> | |
2367
2aff870c2c58
refactoring of BoostConfiguration.cmake
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2253
diff
changeset
|
331 #include <boost/date_time/posix_time/posix_time.hpp> |
1489 | 332 |
333 | |
334 namespace | |
335 { | |
2015
bcc575732aef
New option "--logfile" to output the Orthanc log to the given file
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2014
diff
changeset
|
336 struct LoggingContext |
1489 | 337 { |
1495
fbe40117eb21
improve the performance of the internal logger
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1494
diff
changeset
|
338 bool infoEnabled_; |
fbe40117eb21
improve the performance of the internal logger
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1494
diff
changeset
|
339 bool traceEnabled_; |
2015
bcc575732aef
New option "--logfile" to output the Orthanc log to the given file
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2014
diff
changeset
|
340 std::string targetFile_; |
bcc575732aef
New option "--logfile" to output the Orthanc log to the given file
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2014
diff
changeset
|
341 std::string targetFolder_; |
1495
fbe40117eb21
improve the performance of the internal logger
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1494
diff
changeset
|
342 |
fbe40117eb21
improve the performance of the internal logger
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1494
diff
changeset
|
343 std::ostream* error_; |
fbe40117eb21
improve the performance of the internal logger
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1494
diff
changeset
|
344 std::ostream* warning_; |
fbe40117eb21
improve the performance of the internal logger
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1494
diff
changeset
|
345 std::ostream* info_; |
fbe40117eb21
improve the performance of the internal logger
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1494
diff
changeset
|
346 |
1731
b6f656a0bf2c
"--logdir" creates a single log file instead of 3 separate files for errors/warnings/infos
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1551
diff
changeset
|
347 std::auto_ptr<std::ofstream> file_; |
1495
fbe40117eb21
improve the performance of the internal logger
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1494
diff
changeset
|
348 |
2015
bcc575732aef
New option "--logfile" to output the Orthanc log to the given file
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2014
diff
changeset
|
349 LoggingContext() : |
1495
fbe40117eb21
improve the performance of the internal logger
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1494
diff
changeset
|
350 infoEnabled_(false), |
fbe40117eb21
improve the performance of the internal logger
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1494
diff
changeset
|
351 traceEnabled_(false), |
fbe40117eb21
improve the performance of the internal logger
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1494
diff
changeset
|
352 error_(&std::cerr), |
fbe40117eb21
improve the performance of the internal logger
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1494
diff
changeset
|
353 warning_(&std::cerr), |
fbe40117eb21
improve the performance of the internal logger
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1494
diff
changeset
|
354 info_(&std::cerr) |
1489 | 355 { |
356 } | |
357 }; | |
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
|
358 |
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
|
359 struct LoggingMementoImpl |
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
|
360 { |
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
|
361 bool valid_; |
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
|
362 bool infoEnabled_; |
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
|
363 bool traceEnabled_; |
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
|
364 std::string targetFile_; |
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
|
365 std::string targetFolder_; |
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
|
366 |
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
|
367 std::ostream* error_; |
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
|
368 std::ostream* warning_; |
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
|
369 std::ostream* info_; |
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
|
370 }; |
1489 | 371 } |
372 | |
373 | |
1490
596927722403
support of --logdir by the internal logger
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1489
diff
changeset
|
374 |
2015
bcc575732aef
New option "--logfile" to output the Orthanc log to the given file
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2014
diff
changeset
|
375 static std::auto_ptr<LoggingContext> loggingContext_; |
1495
fbe40117eb21
improve the performance of the internal logger
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1494
diff
changeset
|
376 static boost::mutex loggingMutex_; |
1489 | 377 |
1495
fbe40117eb21
improve the performance of the internal logger
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1494
diff
changeset
|
378 |
1490
596927722403
support of --logdir by the internal logger
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1489
diff
changeset
|
379 |
1489 | 380 namespace Orthanc |
381 { | |
382 namespace Logging | |
383 { | |
1490
596927722403
support of --logdir by the internal logger
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1489
diff
changeset
|
384 static void GetLogPath(boost::filesystem::path& log, |
596927722403
support of --logdir by the internal logger
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1489
diff
changeset
|
385 boost::filesystem::path& link, |
1731
b6f656a0bf2c
"--logdir" creates a single log file instead of 3 separate files for errors/warnings/infos
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1551
diff
changeset
|
386 const std::string& suffix, |
1490
596927722403
support of --logdir by the internal logger
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1489
diff
changeset
|
387 const std::string& directory) |
596927722403
support of --logdir by the internal logger
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1489
diff
changeset
|
388 { |
596927722403
support of --logdir by the internal logger
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1489
diff
changeset
|
389 /** |
596927722403
support of --logdir by the internal logger
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1489
diff
changeset
|
390 From Google Log documentation: |
596927722403
support of --logdir by the internal logger
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1489
diff
changeset
|
391 |
596927722403
support of --logdir by the internal logger
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1489
diff
changeset
|
392 Unless otherwise specified, logs will be written to the filename |
1731
b6f656a0bf2c
"--logdir" creates a single log file instead of 3 separate files for errors/warnings/infos
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1551
diff
changeset
|
393 "<program name>.<hostname>.<user name>.log<suffix>.", |
1490
596927722403
support of --logdir by the internal logger
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1489
diff
changeset
|
394 followed by the date, time, and pid (you can't prevent the date, |
596927722403
support of --logdir by the internal logger
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1489
diff
changeset
|
395 time, and pid from being in the filename). |
596927722403
support of --logdir by the internal logger
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1489
diff
changeset
|
396 |
596927722403
support of --logdir by the internal logger
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1489
diff
changeset
|
397 In this implementation : "hostname" and "username" are not used |
596927722403
support of --logdir by the internal logger
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1489
diff
changeset
|
398 **/ |
596927722403
support of --logdir by the internal logger
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1489
diff
changeset
|
399 |
596927722403
support of --logdir by the internal logger
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1489
diff
changeset
|
400 boost::posix_time::ptime now = boost::posix_time::second_clock::local_time(); |
596927722403
support of --logdir by the internal logger
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1489
diff
changeset
|
401 boost::filesystem::path root(directory); |
2140 | 402 boost::filesystem::path exe(SystemToolbox::GetPathToExecutable()); |
1490
596927722403
support of --logdir by the internal logger
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1489
diff
changeset
|
403 |
596927722403
support of --logdir by the internal logger
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1489
diff
changeset
|
404 if (!boost::filesystem::exists(root) || |
596927722403
support of --logdir by the internal logger
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1489
diff
changeset
|
405 !boost::filesystem::is_directory(root)) |
596927722403
support of --logdir by the internal logger
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1489
diff
changeset
|
406 { |
596927722403
support of --logdir by the internal logger
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1489
diff
changeset
|
407 throw OrthancException(ErrorCode_CannotWriteFile); |
596927722403
support of --logdir by the internal logger
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1489
diff
changeset
|
408 } |
596927722403
support of --logdir by the internal logger
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1489
diff
changeset
|
409 |
596927722403
support of --logdir by the internal logger
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1489
diff
changeset
|
410 char date[64]; |
596927722403
support of --logdir by the internal logger
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1489
diff
changeset
|
411 sprintf(date, "%04d%02d%02d-%02d%02d%02d.%d", |
596927722403
support of --logdir by the internal logger
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1489
diff
changeset
|
412 static_cast<int>(now.date().year()), |
596927722403
support of --logdir by the internal logger
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1489
diff
changeset
|
413 now.date().month().as_number(), |
596927722403
support of --logdir by the internal logger
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1489
diff
changeset
|
414 now.date().day().as_number(), |
2483
9c54c40eaf25
logging primitives for WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
415 static_cast<int>(now.time_of_day().hours()), |
9c54c40eaf25
logging primitives for WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
416 static_cast<int>(now.time_of_day().minutes()), |
9c54c40eaf25
logging primitives for WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
417 static_cast<int>(now.time_of_day().seconds()), |
2140 | 418 SystemToolbox::GetProcessId()); |
1490
596927722403
support of --logdir by the internal logger
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1489
diff
changeset
|
419 |
596927722403
support of --logdir by the internal logger
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1489
diff
changeset
|
420 std::string programName = exe.filename().replace_extension("").string(); |
596927722403
support of --logdir by the internal logger
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1489
diff
changeset
|
421 |
1731
b6f656a0bf2c
"--logdir" creates a single log file instead of 3 separate files for errors/warnings/infos
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1551
diff
changeset
|
422 log = (root / (programName + ".log" + suffix + "." + std::string(date))); |
b6f656a0bf2c
"--logdir" creates a single log file instead of 3 separate files for errors/warnings/infos
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1551
diff
changeset
|
423 link = (root / (programName + ".log" + suffix)); |
1490
596927722403
support of --logdir by the internal logger
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1489
diff
changeset
|
424 } |
596927722403
support of --logdir by the internal logger
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1489
diff
changeset
|
425 |
596927722403
support of --logdir by the internal logger
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1489
diff
changeset
|
426 |
2015
bcc575732aef
New option "--logfile" to output the Orthanc log to the given file
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2014
diff
changeset
|
427 static void PrepareLogFolder(std::auto_ptr<std::ofstream>& file, |
bcc575732aef
New option "--logfile" to output the Orthanc log to the given file
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2014
diff
changeset
|
428 const std::string& suffix, |
bcc575732aef
New option "--logfile" to output the Orthanc log to the given file
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2014
diff
changeset
|
429 const std::string& directory) |
1490
596927722403
support of --logdir by the internal logger
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1489
diff
changeset
|
430 { |
596927722403
support of --logdir by the internal logger
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1489
diff
changeset
|
431 boost::filesystem::path log, link; |
1731
b6f656a0bf2c
"--logdir" creates a single log file instead of 3 separate files for errors/warnings/infos
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1551
diff
changeset
|
432 GetLogPath(log, link, suffix, directory); |
1490
596927722403
support of --logdir by the internal logger
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1489
diff
changeset
|
433 |
596927722403
support of --logdir by the internal logger
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1489
diff
changeset
|
434 #if !defined(_WIN32) && (defined(__unix__) || defined(__unix) || (defined(__APPLE__) && defined(__MACH__))) |
596927722403
support of --logdir by the internal logger
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1489
diff
changeset
|
435 boost::filesystem::remove(link); |
596927722403
support of --logdir by the internal logger
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1489
diff
changeset
|
436 boost::filesystem::create_symlink(log.filename(), link); |
596927722403
support of --logdir by the internal logger
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1489
diff
changeset
|
437 #endif |
596927722403
support of --logdir by the internal logger
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1489
diff
changeset
|
438 |
1494 | 439 file.reset(new std::ofstream(log.string().c_str())); |
1490
596927722403
support of --logdir by the internal logger
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1489
diff
changeset
|
440 } |
596927722403
support of --logdir by the internal logger
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1489
diff
changeset
|
441 |
596927722403
support of --logdir by the internal logger
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1489
diff
changeset
|
442 |
1489 | 443 void Initialize() |
444 { | |
1495
fbe40117eb21
improve the performance of the internal logger
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1494
diff
changeset
|
445 boost::mutex::scoped_lock lock(loggingMutex_); |
2015
bcc575732aef
New option "--logfile" to output the Orthanc log to the given file
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2014
diff
changeset
|
446 loggingContext_.reset(new LoggingContext); |
1489 | 447 } |
448 | |
449 void Finalize() | |
450 { | |
1495
fbe40117eb21
improve the performance of the internal logger
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1494
diff
changeset
|
451 boost::mutex::scoped_lock lock(loggingMutex_); |
2015
bcc575732aef
New option "--logfile" to output the Orthanc log to the given file
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2014
diff
changeset
|
452 loggingContext_.reset(NULL); |
bcc575732aef
New option "--logfile" to output the Orthanc log to the given file
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2014
diff
changeset
|
453 } |
bcc575732aef
New option "--logfile" to output the Orthanc log to the given file
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2014
diff
changeset
|
454 |
bcc575732aef
New option "--logfile" to output the Orthanc log to the given file
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2014
diff
changeset
|
455 void Reset() |
bcc575732aef
New option "--logfile" to output the Orthanc log to the given file
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2014
diff
changeset
|
456 { |
bcc575732aef
New option "--logfile" to output the Orthanc log to the given file
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2014
diff
changeset
|
457 // Recover the old logging context |
bcc575732aef
New option "--logfile" to output the Orthanc log to the given file
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2014
diff
changeset
|
458 std::auto_ptr<LoggingContext> old; |
bcc575732aef
New option "--logfile" to output the Orthanc log to the given file
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2014
diff
changeset
|
459 |
bcc575732aef
New option "--logfile" to output the Orthanc log to the given file
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2014
diff
changeset
|
460 { |
bcc575732aef
New option "--logfile" to output the Orthanc log to the given file
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2014
diff
changeset
|
461 boost::mutex::scoped_lock lock(loggingMutex_); |
bcc575732aef
New option "--logfile" to output the Orthanc log to the given file
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2014
diff
changeset
|
462 if (loggingContext_.get() == NULL) |
bcc575732aef
New option "--logfile" to output the Orthanc log to the given file
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2014
diff
changeset
|
463 { |
bcc575732aef
New option "--logfile" to output the Orthanc log to the given file
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2014
diff
changeset
|
464 return; |
bcc575732aef
New option "--logfile" to output the Orthanc log to the given file
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2014
diff
changeset
|
465 } |
bcc575732aef
New option "--logfile" to output the Orthanc log to the given file
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2014
diff
changeset
|
466 else |
bcc575732aef
New option "--logfile" to output the Orthanc log to the given file
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2014
diff
changeset
|
467 { |
bcc575732aef
New option "--logfile" to output the Orthanc log to the given file
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2014
diff
changeset
|
468 old = loggingContext_; |
bcc575732aef
New option "--logfile" to output the Orthanc log to the given file
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2014
diff
changeset
|
469 |
bcc575732aef
New option "--logfile" to output the Orthanc log to the given file
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2014
diff
changeset
|
470 // Create a new logging context, |
bcc575732aef
New option "--logfile" to output the Orthanc log to the given file
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2014
diff
changeset
|
471 loggingContext_.reset(new LoggingContext); |
bcc575732aef
New option "--logfile" to output the Orthanc log to the given file
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2014
diff
changeset
|
472 } |
bcc575732aef
New option "--logfile" to output the Orthanc log to the given file
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2014
diff
changeset
|
473 } |
bcc575732aef
New option "--logfile" to output the Orthanc log to the given file
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2014
diff
changeset
|
474 |
bcc575732aef
New option "--logfile" to output the Orthanc log to the given file
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2014
diff
changeset
|
475 EnableInfoLevel(old->infoEnabled_); |
bcc575732aef
New option "--logfile" to output the Orthanc log to the given file
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2014
diff
changeset
|
476 EnableTraceLevel(old->traceEnabled_); |
bcc575732aef
New option "--logfile" to output the Orthanc log to the given file
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2014
diff
changeset
|
477 |
bcc575732aef
New option "--logfile" to output the Orthanc log to the given file
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2014
diff
changeset
|
478 if (!old->targetFolder_.empty()) |
bcc575732aef
New option "--logfile" to output the Orthanc log to the given file
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2014
diff
changeset
|
479 { |
bcc575732aef
New option "--logfile" to output the Orthanc log to the given file
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2014
diff
changeset
|
480 SetTargetFolder(old->targetFolder_); |
bcc575732aef
New option "--logfile" to output the Orthanc log to the given file
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2014
diff
changeset
|
481 } |
bcc575732aef
New option "--logfile" to output the Orthanc log to the given file
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2014
diff
changeset
|
482 else if (!old->targetFile_.empty()) |
bcc575732aef
New option "--logfile" to output the Orthanc log to the given file
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2014
diff
changeset
|
483 { |
bcc575732aef
New option "--logfile" to output the Orthanc log to the given file
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2014
diff
changeset
|
484 SetTargetFile(old->targetFile_); |
bcc575732aef
New option "--logfile" to output the Orthanc log to the given file
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2014
diff
changeset
|
485 } |
1489 | 486 } |
487 | |
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
|
488 |
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
|
489 LoggingMemento CreateLoggingMemento() |
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
|
490 { |
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
|
491 LoggingMementoImpl* memento = new LoggingMementoImpl(); |
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
|
492 |
3359
815b81142ff7
Enable custom logging functions to redirect to emscripten specific logging calls
Benjamin Golinvaux <bgo@osimis.io>
parents:
3353
diff
changeset
|
493 memento->valid_ = true; |
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
|
494 { |
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
|
495 boost::mutex::scoped_lock lock(loggingMutex_); |
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
|
496 memento->infoEnabled_ = loggingContext_->infoEnabled_; |
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
|
497 memento->traceEnabled_ = loggingContext_->traceEnabled_; |
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
|
498 memento->targetFile_ = loggingContext_->targetFile_; |
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
|
499 memento->targetFolder_ = loggingContext_->targetFolder_; |
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
|
500 |
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
|
501 memento->error_ = loggingContext_->error_; |
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
|
502 memento->warning_ = loggingContext_->warning_; |
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
|
503 memento->info_ = loggingContext_->info_; |
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
|
504 } |
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
|
505 return reinterpret_cast<void*>(memento); |
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
|
506 } |
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
|
507 |
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
|
508 void RestoreLoggingMemento(LoggingMemento mementoPtr) |
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
|
509 { |
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
|
510 LoggingMementoImpl* memento = |
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
|
511 reinterpret_cast<LoggingMementoImpl*>(mementoPtr); |
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
|
512 if (!memento->valid_) |
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
|
513 throw std::runtime_error("Memento already used"); |
3359
815b81142ff7
Enable custom logging functions to redirect to emscripten specific logging calls
Benjamin Golinvaux <bgo@osimis.io>
parents:
3353
diff
changeset
|
514 memento->valid_ = false; |
3367
b0b5852622e4
Fixed leak in RestoreLoggingMemento
Benjamin Golinvaux <bgo@osimis.io>
parents:
3361
diff
changeset
|
515 std::auto_ptr<LoggingMementoImpl> deleter(memento); |
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
|
516 { |
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
|
517 boost::mutex::scoped_lock lock(loggingMutex_); |
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
|
518 loggingContext_.reset(new LoggingContext); |
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
|
519 loggingContext_->error_ = memento->error_; |
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
|
520 loggingContext_->warning_ = memento->warning_; |
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
|
521 loggingContext_->info_ = memento->info_; |
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
|
522 } |
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
|
523 EnableInfoLevel(memento->infoEnabled_); |
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
|
524 EnableTraceLevel(memento->traceEnabled_); |
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
|
525 if (!memento->targetFolder_.empty()) |
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
|
526 { |
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
|
527 SetTargetFolder(memento->targetFolder_); |
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
|
528 } |
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
|
529 else if (!memento->targetFile_.empty()) |
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
|
530 { |
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
|
531 SetTargetFile(memento->targetFile_); |
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
|
532 } |
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
|
533 } |
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
|
534 |
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
|
535 void DiscardLoggingMemento(LoggingMemento mementoPtr) |
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
|
536 { |
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
|
537 LoggingMementoImpl* memento = |
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
|
538 reinterpret_cast<LoggingMementoImpl*>(mementoPtr); |
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
|
539 delete memento; |
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
|
540 } |
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
|
541 |
1489 | 542 void EnableInfoLevel(bool enabled) |
543 { | |
1495
fbe40117eb21
improve the performance of the internal logger
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1494
diff
changeset
|
544 boost::mutex::scoped_lock lock(loggingMutex_); |
2015
bcc575732aef
New option "--logfile" to output the Orthanc log to the given file
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2014
diff
changeset
|
545 assert(loggingContext_.get() != NULL); |
1495
fbe40117eb21
improve the performance of the internal logger
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1494
diff
changeset
|
546 |
2015
bcc575732aef
New option "--logfile" to output the Orthanc log to the given file
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2014
diff
changeset
|
547 loggingContext_->infoEnabled_ = enabled; |
bcc575732aef
New option "--logfile" to output the Orthanc log to the given file
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2014
diff
changeset
|
548 |
bcc575732aef
New option "--logfile" to output the Orthanc log to the given file
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2014
diff
changeset
|
549 if (!enabled) |
bcc575732aef
New option "--logfile" to output the Orthanc log to the given file
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2014
diff
changeset
|
550 { |
bcc575732aef
New option "--logfile" to output the Orthanc log to the given file
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2014
diff
changeset
|
551 // Also disable the "TRACE" level when info-level debugging is disabled |
bcc575732aef
New option "--logfile" to output the Orthanc log to the given file
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2014
diff
changeset
|
552 loggingContext_->traceEnabled_ = false; |
bcc575732aef
New option "--logfile" to output the Orthanc log to the given file
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2014
diff
changeset
|
553 } |
1489 | 554 } |
555 | |
3359
815b81142ff7
Enable custom logging functions to redirect to emscripten specific logging calls
Benjamin Golinvaux <bgo@osimis.io>
parents:
3353
diff
changeset
|
556 bool IsInfoLevelEnable() |
815b81142ff7
Enable custom logging functions to redirect to emscripten specific logging calls
Benjamin Golinvaux <bgo@osimis.io>
parents:
3353
diff
changeset
|
557 { |
815b81142ff7
Enable custom logging functions to redirect to emscripten specific logging calls
Benjamin Golinvaux <bgo@osimis.io>
parents:
3353
diff
changeset
|
558 boost::mutex::scoped_lock lock(loggingMutex_); |
815b81142ff7
Enable custom logging functions to redirect to emscripten specific logging calls
Benjamin Golinvaux <bgo@osimis.io>
parents:
3353
diff
changeset
|
559 assert(loggingContext_.get() != NULL); |
815b81142ff7
Enable custom logging functions to redirect to emscripten specific logging calls
Benjamin Golinvaux <bgo@osimis.io>
parents:
3353
diff
changeset
|
560 |
815b81142ff7
Enable custom logging functions to redirect to emscripten specific logging calls
Benjamin Golinvaux <bgo@osimis.io>
parents:
3353
diff
changeset
|
561 return loggingContext_->infoEnabled_; |
815b81142ff7
Enable custom logging functions to redirect to emscripten specific logging calls
Benjamin Golinvaux <bgo@osimis.io>
parents:
3353
diff
changeset
|
562 } |
815b81142ff7
Enable custom logging functions to redirect to emscripten specific logging calls
Benjamin Golinvaux <bgo@osimis.io>
parents:
3353
diff
changeset
|
563 |
1489 | 564 void EnableTraceLevel(bool enabled) |
565 { | |
1495
fbe40117eb21
improve the performance of the internal logger
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1494
diff
changeset
|
566 boost::mutex::scoped_lock lock(loggingMutex_); |
2015
bcc575732aef
New option "--logfile" to output the Orthanc log to the given file
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2014
diff
changeset
|
567 assert(loggingContext_.get() != NULL); |
1495
fbe40117eb21
improve the performance of the internal logger
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1494
diff
changeset
|
568 |
2015
bcc575732aef
New option "--logfile" to output the Orthanc log to the given file
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2014
diff
changeset
|
569 loggingContext_->traceEnabled_ = enabled; |
1489 | 570 |
571 if (enabled) | |
572 { | |
1490
596927722403
support of --logdir by the internal logger
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1489
diff
changeset
|
573 // Also enable the "INFO" level when trace-level debugging is enabled |
2015
bcc575732aef
New option "--logfile" to output the Orthanc log to the given file
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2014
diff
changeset
|
574 loggingContext_->infoEnabled_ = true; |
bcc575732aef
New option "--logfile" to output the Orthanc log to the given file
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2014
diff
changeset
|
575 } |
bcc575732aef
New option "--logfile" to output the Orthanc log to the given file
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2014
diff
changeset
|
576 } |
bcc575732aef
New option "--logfile" to output the Orthanc log to the given file
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2014
diff
changeset
|
577 |
3359
815b81142ff7
Enable custom logging functions to redirect to emscripten specific logging calls
Benjamin Golinvaux <bgo@osimis.io>
parents:
3353
diff
changeset
|
578 bool IsTraceLevelEnable() |
815b81142ff7
Enable custom logging functions to redirect to emscripten specific logging calls
Benjamin Golinvaux <bgo@osimis.io>
parents:
3353
diff
changeset
|
579 { |
815b81142ff7
Enable custom logging functions to redirect to emscripten specific logging calls
Benjamin Golinvaux <bgo@osimis.io>
parents:
3353
diff
changeset
|
580 boost::mutex::scoped_lock lock(loggingMutex_); |
815b81142ff7
Enable custom logging functions to redirect to emscripten specific logging calls
Benjamin Golinvaux <bgo@osimis.io>
parents:
3353
diff
changeset
|
581 assert(loggingContext_.get() != NULL); |
815b81142ff7
Enable custom logging functions to redirect to emscripten specific logging calls
Benjamin Golinvaux <bgo@osimis.io>
parents:
3353
diff
changeset
|
582 |
815b81142ff7
Enable custom logging functions to redirect to emscripten specific logging calls
Benjamin Golinvaux <bgo@osimis.io>
parents:
3353
diff
changeset
|
583 return loggingContext_->traceEnabled_; |
815b81142ff7
Enable custom logging functions to redirect to emscripten specific logging calls
Benjamin Golinvaux <bgo@osimis.io>
parents:
3353
diff
changeset
|
584 } |
815b81142ff7
Enable custom logging functions to redirect to emscripten specific logging calls
Benjamin Golinvaux <bgo@osimis.io>
parents:
3353
diff
changeset
|
585 |
2015
bcc575732aef
New option "--logfile" to output the Orthanc log to the given file
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2014
diff
changeset
|
586 |
bcc575732aef
New option "--logfile" to output the Orthanc log to the given file
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2014
diff
changeset
|
587 static void CheckFile(std::auto_ptr<std::ofstream>& f) |
bcc575732aef
New option "--logfile" to output the Orthanc log to the given file
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2014
diff
changeset
|
588 { |
bcc575732aef
New option "--logfile" to output the Orthanc log to the given file
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2014
diff
changeset
|
589 if (loggingContext_->file_.get() == NULL || |
bcc575732aef
New option "--logfile" to output the Orthanc log to the given file
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2014
diff
changeset
|
590 !loggingContext_->file_->is_open()) |
bcc575732aef
New option "--logfile" to output the Orthanc log to the given file
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2014
diff
changeset
|
591 { |
bcc575732aef
New option "--logfile" to output the Orthanc log to the given file
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2014
diff
changeset
|
592 throw OrthancException(ErrorCode_CannotWriteFile); |
1489 | 593 } |
594 } | |
595 | |
596 void SetTargetFolder(const std::string& path) | |
597 { | |
1495
fbe40117eb21
improve the performance of the internal logger
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1494
diff
changeset
|
598 boost::mutex::scoped_lock lock(loggingMutex_); |
2015
bcc575732aef
New option "--logfile" to output the Orthanc log to the given file
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2014
diff
changeset
|
599 assert(loggingContext_.get() != NULL); |
bcc575732aef
New option "--logfile" to output the Orthanc log to the given file
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2014
diff
changeset
|
600 |
bcc575732aef
New option "--logfile" to output the Orthanc log to the given file
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2014
diff
changeset
|
601 PrepareLogFolder(loggingContext_->file_, "" /* no suffix */, path); |
bcc575732aef
New option "--logfile" to output the Orthanc log to the given file
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2014
diff
changeset
|
602 CheckFile(loggingContext_->file_); |
1495
fbe40117eb21
improve the performance of the internal logger
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1494
diff
changeset
|
603 |
2015
bcc575732aef
New option "--logfile" to output the Orthanc log to the given file
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2014
diff
changeset
|
604 loggingContext_->targetFile_.clear(); |
bcc575732aef
New option "--logfile" to output the Orthanc log to the given file
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2014
diff
changeset
|
605 loggingContext_->targetFolder_ = path; |
bcc575732aef
New option "--logfile" to output the Orthanc log to the given file
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2014
diff
changeset
|
606 loggingContext_->warning_ = loggingContext_->file_.get(); |
bcc575732aef
New option "--logfile" to output the Orthanc log to the given file
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2014
diff
changeset
|
607 loggingContext_->error_ = loggingContext_->file_.get(); |
bcc575732aef
New option "--logfile" to output the Orthanc log to the given file
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2014
diff
changeset
|
608 loggingContext_->info_ = loggingContext_->file_.get(); |
bcc575732aef
New option "--logfile" to output the Orthanc log to the given file
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2014
diff
changeset
|
609 } |
bcc575732aef
New option "--logfile" to output the Orthanc log to the given file
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2014
diff
changeset
|
610 |
1731
b6f656a0bf2c
"--logdir" creates a single log file instead of 3 separate files for errors/warnings/infos
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1551
diff
changeset
|
611 |
2015
bcc575732aef
New option "--logfile" to output the Orthanc log to the given file
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2014
diff
changeset
|
612 void SetTargetFile(const std::string& path) |
bcc575732aef
New option "--logfile" to output the Orthanc log to the given file
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2014
diff
changeset
|
613 { |
bcc575732aef
New option "--logfile" to output the Orthanc log to the given file
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2014
diff
changeset
|
614 boost::mutex::scoped_lock lock(loggingMutex_); |
bcc575732aef
New option "--logfile" to output the Orthanc log to the given file
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2014
diff
changeset
|
615 assert(loggingContext_.get() != NULL); |
bcc575732aef
New option "--logfile" to output the Orthanc log to the given file
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2014
diff
changeset
|
616 |
bcc575732aef
New option "--logfile" to output the Orthanc log to the given file
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2014
diff
changeset
|
617 loggingContext_->file_.reset(new std::ofstream(path.c_str(), std::fstream::app)); |
bcc575732aef
New option "--logfile" to output the Orthanc log to the given file
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2014
diff
changeset
|
618 CheckFile(loggingContext_->file_); |
bcc575732aef
New option "--logfile" to output the Orthanc log to the given file
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2014
diff
changeset
|
619 |
bcc575732aef
New option "--logfile" to output the Orthanc log to the given file
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2014
diff
changeset
|
620 loggingContext_->targetFile_ = path; |
bcc575732aef
New option "--logfile" to output the Orthanc log to the given file
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2014
diff
changeset
|
621 loggingContext_->targetFolder_.clear(); |
bcc575732aef
New option "--logfile" to output the Orthanc log to the given file
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2014
diff
changeset
|
622 loggingContext_->warning_ = loggingContext_->file_.get(); |
bcc575732aef
New option "--logfile" to output the Orthanc log to the given file
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2014
diff
changeset
|
623 loggingContext_->error_ = loggingContext_->file_.get(); |
bcc575732aef
New option "--logfile" to output the Orthanc log to the given file
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2014
diff
changeset
|
624 loggingContext_->info_ = loggingContext_->file_.get(); |
1489 | 625 } |
626 | |
2015
bcc575732aef
New option "--logfile" to output the Orthanc log to the given file
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2014
diff
changeset
|
627 |
1489 | 628 InternalLogger::InternalLogger(const char* level, |
629 const char* file, | |
630 int line) : | |
1495
fbe40117eb21
improve the performance of the internal logger
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1494
diff
changeset
|
631 lock_(loggingMutex_), |
fbe40117eb21
improve the performance of the internal logger
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1494
diff
changeset
|
632 stream_(&null_) // By default, logging to "/dev/null" is simulated |
1489 | 633 { |
2015
bcc575732aef
New option "--logfile" to output the Orthanc log to the given file
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2014
diff
changeset
|
634 if (loggingContext_.get() == NULL) |
1489 | 635 { |
1495
fbe40117eb21
improve the performance of the internal logger
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1494
diff
changeset
|
636 fprintf(stderr, "ERROR: Trying to log a message after the finalization of the logging engine\n"); |
fbe40117eb21
improve the performance of the internal logger
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1494
diff
changeset
|
637 return; |
1489 | 638 } |
639 | |
2134
ddc75c6c712d
Avoid hard crash if not enough memory
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2015
diff
changeset
|
640 try |
1495
fbe40117eb21
improve the performance of the internal logger
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1494
diff
changeset
|
641 { |
2134
ddc75c6c712d
Avoid hard crash if not enough memory
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2015
diff
changeset
|
642 LogLevel l = StringToLogLevel(level); |
ddc75c6c712d
Avoid hard crash if not enough memory
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2015
diff
changeset
|
643 |
ddc75c6c712d
Avoid hard crash if not enough memory
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2015
diff
changeset
|
644 if ((l == LogLevel_Info && !loggingContext_->infoEnabled_) || |
ddc75c6c712d
Avoid hard crash if not enough memory
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2015
diff
changeset
|
645 (l == LogLevel_Trace && !loggingContext_->traceEnabled_)) |
ddc75c6c712d
Avoid hard crash if not enough memory
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2015
diff
changeset
|
646 { |
ddc75c6c712d
Avoid hard crash if not enough memory
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2015
diff
changeset
|
647 // This logging level is disabled, directly exit and unlock |
ddc75c6c712d
Avoid hard crash if not enough memory
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2015
diff
changeset
|
648 // the mutex to speed-up things. The stream is set to "/dev/null" |
ddc75c6c712d
Avoid hard crash if not enough memory
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2015
diff
changeset
|
649 lock_.unlock(); |
ddc75c6c712d
Avoid hard crash if not enough memory
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2015
diff
changeset
|
650 return; |
ddc75c6c712d
Avoid hard crash if not enough memory
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2015
diff
changeset
|
651 } |
1495
fbe40117eb21
improve the performance of the internal logger
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1494
diff
changeset
|
652 |
2134
ddc75c6c712d
Avoid hard crash if not enough memory
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2015
diff
changeset
|
653 // Compute the header of the line, temporary release the lock as |
ddc75c6c712d
Avoid hard crash if not enough memory
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2015
diff
changeset
|
654 // this is a time-consuming operation |
ddc75c6c712d
Avoid hard crash if not enough memory
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2015
diff
changeset
|
655 lock_.unlock(); |
ddc75c6c712d
Avoid hard crash if not enough memory
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2015
diff
changeset
|
656 std::string header; |
1495
fbe40117eb21
improve the performance of the internal logger
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1494
diff
changeset
|
657 |
2134
ddc75c6c712d
Avoid hard crash if not enough memory
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2015
diff
changeset
|
658 { |
ddc75c6c712d
Avoid hard crash if not enough memory
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2015
diff
changeset
|
659 boost::filesystem::path path(file); |
ddc75c6c712d
Avoid hard crash if not enough memory
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2015
diff
changeset
|
660 boost::posix_time::ptime now = boost::posix_time::microsec_clock::local_time(); |
ddc75c6c712d
Avoid hard crash if not enough memory
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2015
diff
changeset
|
661 boost::posix_time::time_duration duration = now.time_of_day(); |
1489 | 662 |
2134
ddc75c6c712d
Avoid hard crash if not enough memory
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2015
diff
changeset
|
663 /** |
ddc75c6c712d
Avoid hard crash if not enough memory
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2015
diff
changeset
|
664 From Google Log documentation: |
1489 | 665 |
2134
ddc75c6c712d
Avoid hard crash if not enough memory
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2015
diff
changeset
|
666 "Log lines have this form: |
1489 | 667 |
2134
ddc75c6c712d
Avoid hard crash if not enough memory
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2015
diff
changeset
|
668 Lmmdd hh:mm:ss.uuuuuu threadid file:line] msg... |
1489 | 669 |
2134
ddc75c6c712d
Avoid hard crash if not enough memory
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2015
diff
changeset
|
670 where the fields are defined as follows: |
1489 | 671 |
2134
ddc75c6c712d
Avoid hard crash if not enough memory
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2015
diff
changeset
|
672 L A single character, representing the log level (eg 'I' for INFO) |
ddc75c6c712d
Avoid hard crash if not enough memory
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2015
diff
changeset
|
673 mm The month (zero padded; ie May is '05') |
ddc75c6c712d
Avoid hard crash if not enough memory
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2015
diff
changeset
|
674 dd The day (zero padded) |
ddc75c6c712d
Avoid hard crash if not enough memory
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2015
diff
changeset
|
675 hh:mm:ss.uuuuuu Time in hours, minutes and fractional seconds |
ddc75c6c712d
Avoid hard crash if not enough memory
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2015
diff
changeset
|
676 threadid The space-padded thread ID as returned by GetTID() (this matches the PID on Linux) |
ddc75c6c712d
Avoid hard crash if not enough memory
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2015
diff
changeset
|
677 file The file name |
ddc75c6c712d
Avoid hard crash if not enough memory
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2015
diff
changeset
|
678 line The line number |
ddc75c6c712d
Avoid hard crash if not enough memory
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2015
diff
changeset
|
679 msg The user-supplied message" |
1490
596927722403
support of --logdir by the internal logger
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1489
diff
changeset
|
680 |
2134
ddc75c6c712d
Avoid hard crash if not enough memory
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2015
diff
changeset
|
681 In this implementation, "threadid" is not printed. |
ddc75c6c712d
Avoid hard crash if not enough memory
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2015
diff
changeset
|
682 **/ |
1489 | 683 |
3477
a4f2354f04c3
fix warning from gcc 8.3.0
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3469
diff
changeset
|
684 char date[64]; |
2134
ddc75c6c712d
Avoid hard crash if not enough memory
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2015
diff
changeset
|
685 sprintf(date, "%c%02d%02d %02d:%02d:%02d.%06d ", |
ddc75c6c712d
Avoid hard crash if not enough memory
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2015
diff
changeset
|
686 level[0], |
ddc75c6c712d
Avoid hard crash if not enough memory
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2015
diff
changeset
|
687 now.date().month().as_number(), |
ddc75c6c712d
Avoid hard crash if not enough memory
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2015
diff
changeset
|
688 now.date().day().as_number(), |
2483
9c54c40eaf25
logging primitives for WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
689 static_cast<int>(duration.hours()), |
9c54c40eaf25
logging primitives for WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
690 static_cast<int>(duration.minutes()), |
9c54c40eaf25
logging primitives for WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
691 static_cast<int>(duration.seconds()), |
2134
ddc75c6c712d
Avoid hard crash if not enough memory
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2015
diff
changeset
|
692 static_cast<int>(duration.fractional_seconds())); |
1489 | 693 |
2134
ddc75c6c712d
Avoid hard crash if not enough memory
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2015
diff
changeset
|
694 header = std::string(date) + path.filename().string() + ":" + boost::lexical_cast<std::string>(line) + "] "; |
ddc75c6c712d
Avoid hard crash if not enough memory
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2015
diff
changeset
|
695 } |
1495
fbe40117eb21
improve the performance of the internal logger
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1494
diff
changeset
|
696 |
fbe40117eb21
improve the performance of the internal logger
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1494
diff
changeset
|
697 |
2134
ddc75c6c712d
Avoid hard crash if not enough memory
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2015
diff
changeset
|
698 // The header is computed, we now re-lock the mutex to access |
ddc75c6c712d
Avoid hard crash if not enough memory
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2015
diff
changeset
|
699 // the stream objects. Pay attention that "loggingContext_", |
ddc75c6c712d
Avoid hard crash if not enough memory
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2015
diff
changeset
|
700 // "infoEnabled_" or "traceEnabled_" might have changed while |
ddc75c6c712d
Avoid hard crash if not enough memory
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2015
diff
changeset
|
701 // the mutex was unlocked. |
ddc75c6c712d
Avoid hard crash if not enough memory
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2015
diff
changeset
|
702 lock_.lock(); |
ddc75c6c712d
Avoid hard crash if not enough memory
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2015
diff
changeset
|
703 |
ddc75c6c712d
Avoid hard crash if not enough memory
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2015
diff
changeset
|
704 if (loggingContext_.get() == NULL) |
ddc75c6c712d
Avoid hard crash if not enough memory
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2015
diff
changeset
|
705 { |
ddc75c6c712d
Avoid hard crash if not enough memory
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2015
diff
changeset
|
706 fprintf(stderr, "ERROR: Trying to log a message after the finalization of the logging engine\n"); |
ddc75c6c712d
Avoid hard crash if not enough memory
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2015
diff
changeset
|
707 return; |
ddc75c6c712d
Avoid hard crash if not enough memory
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2015
diff
changeset
|
708 } |
1495
fbe40117eb21
improve the performance of the internal logger
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1494
diff
changeset
|
709 |
2134
ddc75c6c712d
Avoid hard crash if not enough memory
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2015
diff
changeset
|
710 switch (l) |
ddc75c6c712d
Avoid hard crash if not enough memory
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2015
diff
changeset
|
711 { |
ddc75c6c712d
Avoid hard crash if not enough memory
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2015
diff
changeset
|
712 case LogLevel_Error: |
ddc75c6c712d
Avoid hard crash if not enough memory
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2015
diff
changeset
|
713 stream_ = loggingContext_->error_; |
ddc75c6c712d
Avoid hard crash if not enough memory
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2015
diff
changeset
|
714 break; |
1495
fbe40117eb21
improve the performance of the internal logger
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1494
diff
changeset
|
715 |
2134
ddc75c6c712d
Avoid hard crash if not enough memory
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2015
diff
changeset
|
716 case LogLevel_Warning: |
ddc75c6c712d
Avoid hard crash if not enough memory
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2015
diff
changeset
|
717 stream_ = loggingContext_->warning_; |
ddc75c6c712d
Avoid hard crash if not enough memory
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2015
diff
changeset
|
718 break; |
1495
fbe40117eb21
improve the performance of the internal logger
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1494
diff
changeset
|
719 |
2134
ddc75c6c712d
Avoid hard crash if not enough memory
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2015
diff
changeset
|
720 case LogLevel_Info: |
ddc75c6c712d
Avoid hard crash if not enough memory
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2015
diff
changeset
|
721 if (loggingContext_->infoEnabled_) |
ddc75c6c712d
Avoid hard crash if not enough memory
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2015
diff
changeset
|
722 { |
ddc75c6c712d
Avoid hard crash if not enough memory
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2015
diff
changeset
|
723 stream_ = loggingContext_->info_; |
ddc75c6c712d
Avoid hard crash if not enough memory
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2015
diff
changeset
|
724 } |
ddc75c6c712d
Avoid hard crash if not enough memory
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2015
diff
changeset
|
725 |
ddc75c6c712d
Avoid hard crash if not enough memory
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2015
diff
changeset
|
726 break; |
1495
fbe40117eb21
improve the performance of the internal logger
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1494
diff
changeset
|
727 |
2134
ddc75c6c712d
Avoid hard crash if not enough memory
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2015
diff
changeset
|
728 case LogLevel_Trace: |
ddc75c6c712d
Avoid hard crash if not enough memory
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2015
diff
changeset
|
729 if (loggingContext_->traceEnabled_) |
ddc75c6c712d
Avoid hard crash if not enough memory
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2015
diff
changeset
|
730 { |
ddc75c6c712d
Avoid hard crash if not enough memory
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2015
diff
changeset
|
731 stream_ = loggingContext_->info_; |
ddc75c6c712d
Avoid hard crash if not enough memory
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2015
diff
changeset
|
732 } |
1495
fbe40117eb21
improve the performance of the internal logger
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1494
diff
changeset
|
733 |
2134
ddc75c6c712d
Avoid hard crash if not enough memory
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2015
diff
changeset
|
734 break; |
1495
fbe40117eb21
improve the performance of the internal logger
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1494
diff
changeset
|
735 |
2134
ddc75c6c712d
Avoid hard crash if not enough memory
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2015
diff
changeset
|
736 default: |
ddc75c6c712d
Avoid hard crash if not enough memory
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2015
diff
changeset
|
737 throw OrthancException(ErrorCode_InternalError); |
ddc75c6c712d
Avoid hard crash if not enough memory
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2015
diff
changeset
|
738 } |
1495
fbe40117eb21
improve the performance of the internal logger
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1494
diff
changeset
|
739 |
2134
ddc75c6c712d
Avoid hard crash if not enough memory
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2015
diff
changeset
|
740 if (stream_ == &null_) |
ddc75c6c712d
Avoid hard crash if not enough memory
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2015
diff
changeset
|
741 { |
ddc75c6c712d
Avoid hard crash if not enough memory
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2015
diff
changeset
|
742 // The logging is disabled for this level. The stream is the |
ddc75c6c712d
Avoid hard crash if not enough memory
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2015
diff
changeset
|
743 // "null_" member of this object, so we can release the global |
ddc75c6c712d
Avoid hard crash if not enough memory
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2015
diff
changeset
|
744 // mutex. |
ddc75c6c712d
Avoid hard crash if not enough memory
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2015
diff
changeset
|
745 lock_.unlock(); |
ddc75c6c712d
Avoid hard crash if not enough memory
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2015
diff
changeset
|
746 } |
1495
fbe40117eb21
improve the performance of the internal logger
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1494
diff
changeset
|
747 |
2134
ddc75c6c712d
Avoid hard crash if not enough memory
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2015
diff
changeset
|
748 (*stream_) << header; |
1495
fbe40117eb21
improve the performance of the internal logger
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1494
diff
changeset
|
749 } |
2134
ddc75c6c712d
Avoid hard crash if not enough memory
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2015
diff
changeset
|
750 catch (...) |
ddc75c6c712d
Avoid hard crash if not enough memory
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2015
diff
changeset
|
751 { |
ddc75c6c712d
Avoid hard crash if not enough memory
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2015
diff
changeset
|
752 // Something is going really wrong, probably running out of |
ddc75c6c712d
Avoid hard crash if not enough memory
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2015
diff
changeset
|
753 // memory. Fallback to a degraded mode. |
ddc75c6c712d
Avoid hard crash if not enough memory
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2015
diff
changeset
|
754 stream_ = loggingContext_->error_; |
ddc75c6c712d
Avoid hard crash if not enough memory
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2015
diff
changeset
|
755 (*stream_) << "E???? ??:??:??.?????? ] "; |
ddc75c6c712d
Avoid hard crash if not enough memory
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2015
diff
changeset
|
756 } |
1489 | 757 } |
1507 | 758 |
759 | |
760 InternalLogger::~InternalLogger() | |
761 { | |
762 if (stream_ != &null_) | |
763 { | |
764 *stream_ << "\n"; | |
765 stream_->flush(); | |
766 } | |
767 } | |
768 | |
769 | |
2015
bcc575732aef
New option "--logfile" to output the Orthanc log to the given file
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2014
diff
changeset
|
770 void Flush() |
bcc575732aef
New option "--logfile" to output the Orthanc log to the given file
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2014
diff
changeset
|
771 { |
bcc575732aef
New option "--logfile" to output the Orthanc log to the given file
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2014
diff
changeset
|
772 boost::mutex::scoped_lock lock(loggingMutex_); |
bcc575732aef
New option "--logfile" to output the Orthanc log to the given file
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2014
diff
changeset
|
773 |
bcc575732aef
New option "--logfile" to output the Orthanc log to the given file
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2014
diff
changeset
|
774 if (loggingContext_.get() != NULL && |
bcc575732aef
New option "--logfile" to output the Orthanc log to the given file
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2014
diff
changeset
|
775 loggingContext_->file_.get() != NULL) |
bcc575732aef
New option "--logfile" to output the Orthanc log to the given file
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2014
diff
changeset
|
776 { |
bcc575732aef
New option "--logfile" to output the Orthanc log to the given file
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2014
diff
changeset
|
777 loggingContext_->file_->flush(); |
bcc575732aef
New option "--logfile" to output the Orthanc log to the given file
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2014
diff
changeset
|
778 } |
bcc575732aef
New option "--logfile" to output the Orthanc log to the given file
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2014
diff
changeset
|
779 } |
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
|
780 |
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
|
781 void SetErrorWarnInfoLoggingStreams(std::ostream* errorStream, |
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
|
782 std::ostream* warningStream, |
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
|
783 std::ostream* infoStream) |
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
|
784 { |
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
|
785 boost::mutex::scoped_lock lock(loggingMutex_); |
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
|
786 std::auto_ptr<LoggingContext> old = loggingContext_; |
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
|
787 loggingContext_.reset(new LoggingContext); |
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
|
788 loggingContext_->error_ = errorStream; |
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
|
789 loggingContext_->warning_ = warningStream; |
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
|
790 loggingContext_->info_ = infoStream; |
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
|
791 lock.unlock(); |
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
|
792 EnableInfoLevel(old->infoEnabled_); |
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
|
793 EnableTraceLevel(old->traceEnabled_); |
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
|
794 } |
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
|
795 |
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
|
796 #ifdef __EMSCRIPTEN__ |
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
|
797 |
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
|
798 FuncStreamBuf<decltype(emscripten_console_error)> |
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
|
799 globalEmscriptenErrorStreamBuf(emscripten_console_error); |
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
|
800 std::auto_ptr<std::ostream> globalEmscriptenErrorStream; |
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
|
801 |
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
|
802 FuncStreamBuf<decltype(emscripten_console_warn)> |
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
|
803 globalEmscriptenWarningStreamBuf(emscripten_console_warn); |
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
|
804 std::auto_ptr<std::ostream> globalEmscriptenWarningStream; |
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
|
805 |
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
|
806 FuncStreamBuf<decltype(emscripten_console_log)> |
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
|
807 globalEmscriptenInfoStreamBuf(emscripten_console_log); |
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
|
808 std::auto_ptr<std::ostream> globalEmscriptenInfoStream; |
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
|
809 |
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
|
810 void EnableEmscriptenLogging() |
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
|
811 { |
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
|
812 globalEmscriptenErrorStream.reset(new ostream( |
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
|
813 &globalEmscriptenErrorStreamBuf)); |
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
|
814 |
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
|
815 globalEmscriptenWarningStream.reset(new ostream( |
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
|
816 &globalEmscriptenWarningStreamBuf)); |
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
|
817 |
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
|
818 globalEmscriptenInfoStream.reset(new ostream( |
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
|
819 &globalEmscriptenInfoStreamBuf)); |
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
|
820 |
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
|
821 SetErrorWarnInfoLoggingStreams( |
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
|
822 &globalEmscriptenErrorStream, |
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
|
823 &globalEmscriptenWarningStream |
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
|
824 &globalEmscriptenInfoStream); |
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
|
825 } |
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
|
826 #endif |
1485 | 827 } |
828 } | |
1488 | 829 |
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
|
830 |
1489 | 831 #endif // ORTHANC_ENABLE_LOGGING |