annotate Resources/Orthanc/Core/Logging.h @ 59:d2adc6189a95 wasm

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