Mercurial > hg > orthanc-stone
annotate Resources/Orthanc/Core/Logging.h @ 210:101e487cd154
updated bibtex
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Fri, 04 May 2018 10:39:04 +0200 |
parents | e7f90aba3c97 |
children |
rev | line source |
---|---|
200
03afbee0cc7b
integration of Orthanc core into Stone
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1 /** |
03afbee0cc7b
integration of Orthanc core into Stone
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2 * Orthanc - A Lightweight, RESTful DICOM Store |
03afbee0cc7b
integration of Orthanc core into Stone
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
3 * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics |
03afbee0cc7b
integration of Orthanc core into Stone
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
4 * Department, University Hospital of Liege, Belgium |
03afbee0cc7b
integration of Orthanc core into Stone
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
5 * Copyright (C) 2017-2018 Osimis S.A., Belgium |
03afbee0cc7b
integration of Orthanc core into Stone
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
6 * |
03afbee0cc7b
integration of Orthanc core into Stone
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
7 * This program is free software: you can redistribute it and/or |
03afbee0cc7b
integration of Orthanc core into Stone
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
8 * modify it under the terms of the GNU General Public License as |
03afbee0cc7b
integration of Orthanc core into Stone
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
9 * published by the Free Software Foundation, either version 3 of the |
03afbee0cc7b
integration of Orthanc core into Stone
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
10 * License, or (at your option) any later version. |
03afbee0cc7b
integration of Orthanc core into Stone
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
11 * |
03afbee0cc7b
integration of Orthanc core into Stone
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
12 * In addition, as a special exception, the copyright holders of this |
03afbee0cc7b
integration of Orthanc core into Stone
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
13 * program give permission to link the code of its release with the |
03afbee0cc7b
integration of Orthanc core into Stone
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
14 * OpenSSL project's "OpenSSL" library (or with modified versions of it |
03afbee0cc7b
integration of Orthanc core into Stone
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
15 * that use the same license as the "OpenSSL" library), and distribute |
03afbee0cc7b
integration of Orthanc core into Stone
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
16 * the linked executables. You must obey the GNU General Public License |
03afbee0cc7b
integration of Orthanc core into Stone
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
17 * in all respects for all of the code used other than "OpenSSL". If you |
03afbee0cc7b
integration of Orthanc core into Stone
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
18 * modify file(s) with this exception, you may extend this exception to |
03afbee0cc7b
integration of Orthanc core into Stone
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
19 * your version of the file(s), but you are not obligated to do so. If |
03afbee0cc7b
integration of Orthanc core into Stone
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
20 * you do not wish to do so, delete this exception statement from your |
03afbee0cc7b
integration of Orthanc core into Stone
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
21 * version. If you delete this exception statement from all source files |
03afbee0cc7b
integration of Orthanc core into Stone
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
22 * in the program, then also delete it here. |
03afbee0cc7b
integration of Orthanc core into Stone
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
23 * |
03afbee0cc7b
integration of Orthanc core into Stone
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
24 * This program is distributed in the hope that it will be useful, but |
03afbee0cc7b
integration of Orthanc core into Stone
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
25 * WITHOUT ANY WARRANTY; without even the implied warranty of |
03afbee0cc7b
integration of Orthanc core into Stone
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
26 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
03afbee0cc7b
integration of Orthanc core into Stone
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
27 * General Public License for more details. |
03afbee0cc7b
integration of Orthanc core into Stone
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
28 * |
03afbee0cc7b
integration of Orthanc core into Stone
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
29 * You should have received a copy of the GNU General Public License |
03afbee0cc7b
integration of Orthanc core into Stone
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
30 * along with this program. If not, see <http://www.gnu.org/licenses/>. |
03afbee0cc7b
integration of Orthanc core into Stone
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
31 **/ |
03afbee0cc7b
integration of Orthanc core into Stone
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
32 |
03afbee0cc7b
integration of Orthanc core into Stone
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
33 |
03afbee0cc7b
integration of Orthanc core into Stone
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
34 #pragma once |
03afbee0cc7b
integration of Orthanc core into Stone
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
35 |
03afbee0cc7b
integration of Orthanc core into Stone
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
36 #include <iostream> |
03afbee0cc7b
integration of Orthanc core into Stone
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
37 |
03afbee0cc7b
integration of Orthanc core into Stone
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
38 #if !defined(ORTHANC_ENABLE_LOGGING) |
03afbee0cc7b
integration of Orthanc core into Stone
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
39 # error The macro ORTHANC_ENABLE_LOGGING must be defined |
03afbee0cc7b
integration of Orthanc core into Stone
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
40 #endif |
03afbee0cc7b
integration of Orthanc core into Stone
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
41 |
03afbee0cc7b
integration of Orthanc core into Stone
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
42 #if !defined(ORTHANC_ENABLE_LOGGING_PLUGIN) |
03afbee0cc7b
integration of Orthanc core into Stone
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
43 # if ORTHANC_ENABLE_LOGGING == 1 |
03afbee0cc7b
integration of Orthanc core into Stone
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
44 # error The macro ORTHANC_ENABLE_LOGGING_PLUGIN must be defined |
03afbee0cc7b
integration of Orthanc core into Stone
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
45 # else |
03afbee0cc7b
integration of Orthanc core into Stone
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
46 # define ORTHANC_ENABLE_LOGGING_PLUGIN 0 |
03afbee0cc7b
integration of Orthanc core into Stone
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
47 # endif |
03afbee0cc7b
integration of Orthanc core into Stone
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
48 #endif |
03afbee0cc7b
integration of Orthanc core into Stone
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
49 |
03afbee0cc7b
integration of Orthanc core into Stone
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
50 #if !defined(ORTHANC_ENABLE_LOGGING_STDIO) |
03afbee0cc7b
integration of Orthanc core into Stone
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
51 # if ORTHANC_ENABLE_LOGGING == 1 |
03afbee0cc7b
integration of Orthanc core into Stone
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
52 # error The macro ORTHANC_ENABLE_LOGGING_STDIO must be defined |
03afbee0cc7b
integration of Orthanc core into Stone
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
53 # else |
03afbee0cc7b
integration of Orthanc core into Stone
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
54 # define ORTHANC_ENABLE_LOGGING_STDIO 0 |
03afbee0cc7b
integration of Orthanc core into Stone
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
55 # endif |
03afbee0cc7b
integration of Orthanc core into Stone
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
56 #endif |
03afbee0cc7b
integration of Orthanc core into Stone
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
57 |
03afbee0cc7b
integration of Orthanc core into Stone
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
58 #if ORTHANC_ENABLE_LOGGING_PLUGIN == 1 |
03afbee0cc7b
integration of Orthanc core into Stone
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
59 # include <orthanc/OrthancCPlugin.h> |
03afbee0cc7b
integration of Orthanc core into Stone
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
60 #endif |
03afbee0cc7b
integration of Orthanc core into Stone
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
61 |
202 | 62 #include <boost/lexical_cast.hpp> |
63 | |
200
03afbee0cc7b
integration of Orthanc core into Stone
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
64 namespace Orthanc |
03afbee0cc7b
integration of Orthanc core into Stone
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
65 { |
03afbee0cc7b
integration of Orthanc core into Stone
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
66 namespace Logging |
03afbee0cc7b
integration of Orthanc core into Stone
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
67 { |
03afbee0cc7b
integration of Orthanc core into Stone
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
68 #if ORTHANC_ENABLE_LOGGING_PLUGIN == 1 |
03afbee0cc7b
integration of Orthanc core into Stone
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
69 void Initialize(OrthancPluginContext* context); |
03afbee0cc7b
integration of Orthanc core into Stone
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
70 #else |
03afbee0cc7b
integration of Orthanc core into Stone
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
71 void Initialize(); |
03afbee0cc7b
integration of Orthanc core into Stone
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
72 #endif |
03afbee0cc7b
integration of Orthanc core into Stone
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
73 |
03afbee0cc7b
integration of Orthanc core into Stone
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
74 void Finalize(); |
03afbee0cc7b
integration of Orthanc core into Stone
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
75 |
03afbee0cc7b
integration of Orthanc core into Stone
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
76 void Reset(); |
03afbee0cc7b
integration of Orthanc core into Stone
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
77 |
03afbee0cc7b
integration of Orthanc core into Stone
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
78 void Flush(); |
03afbee0cc7b
integration of Orthanc core into Stone
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
79 |
03afbee0cc7b
integration of Orthanc core into Stone
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
80 void EnableInfoLevel(bool enabled); |
03afbee0cc7b
integration of Orthanc core into Stone
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
81 |
03afbee0cc7b
integration of Orthanc core into Stone
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
82 void EnableTraceLevel(bool enabled); |
03afbee0cc7b
integration of Orthanc core into Stone
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
83 |
03afbee0cc7b
integration of Orthanc core into Stone
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
84 void SetTargetFile(const std::string& path); |
03afbee0cc7b
integration of Orthanc core into Stone
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
85 |
03afbee0cc7b
integration of Orthanc core into Stone
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
86 void SetTargetFolder(const std::string& path); |
03afbee0cc7b
integration of Orthanc core into Stone
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
87 |
03afbee0cc7b
integration of Orthanc core into Stone
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
88 struct NullStream : public std::ostream |
03afbee0cc7b
integration of Orthanc core into Stone
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
89 { |
03afbee0cc7b
integration of Orthanc core into Stone
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
90 NullStream() : |
03afbee0cc7b
integration of Orthanc core into Stone
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
91 std::ios(0), |
03afbee0cc7b
integration of Orthanc core into Stone
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
92 std::ostream(0) |
03afbee0cc7b
integration of Orthanc core into Stone
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
93 { |
03afbee0cc7b
integration of Orthanc core into Stone
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
94 } |
03afbee0cc7b
integration of Orthanc core into Stone
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
95 |
202 | 96 template <typename T> |
97 std::ostream& operator<< (const T& message) | |
200
03afbee0cc7b
integration of Orthanc core into Stone
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
98 { |
03afbee0cc7b
integration of Orthanc core into Stone
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
99 return *this; |
03afbee0cc7b
integration of Orthanc core into Stone
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
100 } |
03afbee0cc7b
integration of Orthanc core into Stone
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
101 }; |
03afbee0cc7b
integration of Orthanc core into Stone
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
102 } |
03afbee0cc7b
integration of Orthanc core into Stone
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
103 } |
03afbee0cc7b
integration of Orthanc core into Stone
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
104 |
03afbee0cc7b
integration of Orthanc core into Stone
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
105 |
03afbee0cc7b
integration of Orthanc core into Stone
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
106 #if ORTHANC_ENABLE_LOGGING != 1 |
03afbee0cc7b
integration of Orthanc core into Stone
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
107 |
03afbee0cc7b
integration of Orthanc core into Stone
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
108 # define LOG(level) ::Orthanc::Logging::NullStream() |
03afbee0cc7b
integration of Orthanc core into Stone
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
109 # define VLOG(level) ::Orthanc::Logging::NullStream() |
03afbee0cc7b
integration of Orthanc core into Stone
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
110 |
03afbee0cc7b
integration of Orthanc core into Stone
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
111 |
03afbee0cc7b
integration of Orthanc core into Stone
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
112 #elif (ORTHANC_ENABLE_LOGGING_PLUGIN == 1 || \ |
03afbee0cc7b
integration of Orthanc core into Stone
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
113 ORTHANC_ENABLE_LOGGING_STDIO == 1) |
03afbee0cc7b
integration of Orthanc core into Stone
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
114 |
03afbee0cc7b
integration of Orthanc core into Stone
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
115 # include <boost/noncopyable.hpp> |
03afbee0cc7b
integration of Orthanc core into Stone
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
116 # define LOG(level) ::Orthanc::Logging::InternalLogger \ |
202 | 117 (::Orthanc::Logging::InternalLevel_ ## level, __FILE__, __LINE__) |
200
03afbee0cc7b
integration of Orthanc core into Stone
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
118 # define VLOG(level) ::Orthanc::Logging::InternalLogger \ |
202 | 119 (::Orthanc::Logging::InternalLevel_TRACE, __FILE__, __LINE__) |
200
03afbee0cc7b
integration of Orthanc core into Stone
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
120 |
03afbee0cc7b
integration of Orthanc core into Stone
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
121 namespace Orthanc |
03afbee0cc7b
integration of Orthanc core into Stone
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
122 { |
03afbee0cc7b
integration of Orthanc core into Stone
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
123 namespace Logging |
03afbee0cc7b
integration of Orthanc core into Stone
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
124 { |
202 | 125 enum InternalLevel |
200
03afbee0cc7b
integration of Orthanc core into Stone
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
126 { |
202 | 127 InternalLevel_ERROR, |
128 InternalLevel_WARNING, | |
129 InternalLevel_INFO, | |
130 InternalLevel_TRACE | |
200
03afbee0cc7b
integration of Orthanc core into Stone
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
131 }; |
03afbee0cc7b
integration of Orthanc core into Stone
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
132 |
03afbee0cc7b
integration of Orthanc core into Stone
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
133 class InternalLogger : public boost::noncopyable |
03afbee0cc7b
integration of Orthanc core into Stone
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
134 { |
03afbee0cc7b
integration of Orthanc core into Stone
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
135 private: |
202 | 136 InternalLevel level_; |
137 std::string message_; | |
200
03afbee0cc7b
integration of Orthanc core into Stone
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
138 |
03afbee0cc7b
integration of Orthanc core into Stone
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
139 public: |
202 | 140 InternalLogger(InternalLevel level, |
200
03afbee0cc7b
integration of Orthanc core into Stone
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
141 const char* file, |
03afbee0cc7b
integration of Orthanc core into Stone
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
142 int line); |
03afbee0cc7b
integration of Orthanc core into Stone
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
143 |
03afbee0cc7b
integration of Orthanc core into Stone
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
144 ~InternalLogger(); |
03afbee0cc7b
integration of Orthanc core into Stone
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
145 |
03afbee0cc7b
integration of Orthanc core into Stone
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
146 template <typename T> |
202 | 147 InternalLogger& operator<< (const T& message) |
200
03afbee0cc7b
integration of Orthanc core into Stone
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
148 { |
03afbee0cc7b
integration of Orthanc core into Stone
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
149 message_ += boost::lexical_cast<std::string>(message); |
03afbee0cc7b
integration of Orthanc core into Stone
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
150 return *this; |
03afbee0cc7b
integration of Orthanc core into Stone
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
151 } |
03afbee0cc7b
integration of Orthanc core into Stone
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
152 }; |
03afbee0cc7b
integration of Orthanc core into Stone
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
153 } |
03afbee0cc7b
integration of Orthanc core into Stone
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
154 } |
03afbee0cc7b
integration of Orthanc core into Stone
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
155 |
03afbee0cc7b
integration of Orthanc core into Stone
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
156 |
03afbee0cc7b
integration of Orthanc core into Stone
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
157 |
03afbee0cc7b
integration of Orthanc core into Stone
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
158 |
03afbee0cc7b
integration of Orthanc core into Stone
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
159 #else /* ORTHANC_ENABLE_LOGGING_PLUGIN == 0 && |
03afbee0cc7b
integration of Orthanc core into Stone
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
160 ORTHANC_ENABLE_LOGGING_STDIO == 0 && |
03afbee0cc7b
integration of Orthanc core into Stone
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
161 ORTHANC_ENABLE_LOGGING == 1 */ |
03afbee0cc7b
integration of Orthanc core into Stone
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
162 |
03afbee0cc7b
integration of Orthanc core into Stone
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
163 # include <boost/thread/mutex.hpp> |
03afbee0cc7b
integration of Orthanc core into Stone
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
164 # define LOG(level) ::Orthanc::Logging::InternalLogger(#level, __FILE__, __LINE__) |
03afbee0cc7b
integration of Orthanc core into Stone
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
165 # define VLOG(level) ::Orthanc::Logging::InternalLogger("TRACE", __FILE__, __LINE__) |
03afbee0cc7b
integration of Orthanc core into Stone
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
166 |
03afbee0cc7b
integration of Orthanc core into Stone
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
167 namespace Orthanc |
03afbee0cc7b
integration of Orthanc core into Stone
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
168 { |
03afbee0cc7b
integration of Orthanc core into Stone
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
169 namespace Logging |
03afbee0cc7b
integration of Orthanc core into Stone
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
170 { |
03afbee0cc7b
integration of Orthanc core into Stone
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
171 class InternalLogger |
03afbee0cc7b
integration of Orthanc core into Stone
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
172 { |
03afbee0cc7b
integration of Orthanc core into Stone
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
173 private: |
03afbee0cc7b
integration of Orthanc core into Stone
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
174 boost::mutex::scoped_lock lock_; |
03afbee0cc7b
integration of Orthanc core into Stone
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
175 NullStream null_; |
03afbee0cc7b
integration of Orthanc core into Stone
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
176 std::ostream* stream_; |
03afbee0cc7b
integration of Orthanc core into Stone
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
177 |
03afbee0cc7b
integration of Orthanc core into Stone
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
178 public: |
03afbee0cc7b
integration of Orthanc core into Stone
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
179 InternalLogger(const char* level, |
03afbee0cc7b
integration of Orthanc core into Stone
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
180 const char* file, |
03afbee0cc7b
integration of Orthanc core into Stone
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
181 int line); |
03afbee0cc7b
integration of Orthanc core into Stone
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
182 |
03afbee0cc7b
integration of Orthanc core into Stone
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
183 ~InternalLogger(); |
03afbee0cc7b
integration of Orthanc core into Stone
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
184 |
202 | 185 template <typename T> |
186 std::ostream& operator<< (const T& message) | |
200
03afbee0cc7b
integration of Orthanc core into Stone
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
187 { |
202 | 188 return (*stream_) << boost::lexical_cast<std::string>(message); |
200
03afbee0cc7b
integration of Orthanc core into Stone
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
189 } |
03afbee0cc7b
integration of Orthanc core into Stone
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
190 }; |
03afbee0cc7b
integration of Orthanc core into Stone
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
191 } |
03afbee0cc7b
integration of Orthanc core into Stone
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
192 } |
03afbee0cc7b
integration of Orthanc core into Stone
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
193 |
03afbee0cc7b
integration of Orthanc core into Stone
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
194 #endif // ORTHANC_ENABLE_LOGGING |