comparison Core/Logging.h @ 2504:78862372ea88

fix msvc build
author Sebastien Jodogne <s.jodogne@gmail.com>
date Mon, 26 Mar 2018 10:13:50 +0200
parents 911e62dbb4ac
children a4f885670da7
comparison
equal deleted inserted replaced
2503:2717a8872396 2504:78862372ea88
57 57
58 #if ORTHANC_ENABLE_LOGGING_PLUGIN == 1 58 #if ORTHANC_ENABLE_LOGGING_PLUGIN == 1
59 # include <orthanc/OrthancCPlugin.h> 59 # include <orthanc/OrthancCPlugin.h>
60 #endif 60 #endif
61 61
62 #include <boost/lexical_cast.hpp>
63
62 namespace Orthanc 64 namespace Orthanc
63 { 65 {
64 namespace Logging 66 namespace Logging
65 { 67 {
66 #if ORTHANC_ENABLE_LOGGING_PLUGIN == 1 68 #if ORTHANC_ENABLE_LOGGING_PLUGIN == 1
89 std::ios(0), 91 std::ios(0),
90 std::ostream(0) 92 std::ostream(0)
91 { 93 {
92 } 94 }
93 95
94 std::ostream& operator<< (const std::string& message) 96 template <typename T>
95 { 97 std::ostream& operator<< (const T& message)
96 return *this;
97 }
98
99 // This overload fixes build problems with Visual Studio 2015
100 std::ostream& operator<< (const char* message)
101 { 98 {
102 return *this; 99 return *this;
103 } 100 }
104 }; 101 };
105 } 102 }
114 111
115 #elif (ORTHANC_ENABLE_LOGGING_PLUGIN == 1 || \ 112 #elif (ORTHANC_ENABLE_LOGGING_PLUGIN == 1 || \
116 ORTHANC_ENABLE_LOGGING_STDIO == 1) 113 ORTHANC_ENABLE_LOGGING_STDIO == 1)
117 114
118 # include <boost/noncopyable.hpp> 115 # include <boost/noncopyable.hpp>
119 # include <boost/lexical_cast.hpp>
120 # define LOG(level) ::Orthanc::Logging::InternalLogger \ 116 # define LOG(level) ::Orthanc::Logging::InternalLogger \
121 (::Orthanc::Logging::level, __FILE__, __LINE__) 117 (::Orthanc::Logging::level, __FILE__, __LINE__)
122 # define VLOG(level) ::Orthanc::Logging::InternalLogger \ 118 # define VLOG(level) ::Orthanc::Logging::InternalLogger \
123 (::Orthanc::Logging::TRACE, __FILE__, __LINE__) 119 (::Orthanc::Logging::TRACE, __FILE__, __LINE__)
124 120
146 int line); 142 int line);
147 143
148 ~InternalLogger(); 144 ~InternalLogger();
149 145
150 template <typename T> 146 template <typename T>
151 InternalLogger& operator<< (T message) 147 InternalLogger& operator<< (const T& message)
152 { 148 {
153 message_ += boost::lexical_cast<std::string>(message); 149 message_ += boost::lexical_cast<std::string>(message);
154 return *this; 150 return *this;
155 } 151 }
156 }; 152 };
184 const char* file, 180 const char* file,
185 int line); 181 int line);
186 182
187 ~InternalLogger(); 183 ~InternalLogger();
188 184
189 std::ostream& operator<< (const std::string& message) 185 template <typename T>
186 std::ostream& operator<< (const T& message)
190 { 187 {
191 return (*stream_) << message; 188 return (*stream_) << boost::lexical_cast<std::string>(message);
192 }
193
194 // This overload fixes build problems with Visual Studio 2015
195 std::ostream& operator<< (const char* message)
196 {
197 return (*stream_) << message;
198 } 189 }
199 }; 190 };
200 } 191 }
201 } 192 }
202 193