Mercurial > hg > orthanc
comparison OrthancServer/Plugins/Samples/Common/OrthancPluginCppWrapper.cpp @ 5575:d7eaa568da15
Orthanc::Logging automatically detects whether the Orthanc core supports OrthancPluginLogMessage()
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Fri, 26 Apr 2024 17:17:34 +0200 |
parents | f0dc99bc811c |
children | f7adfb22e20e |
comparison
equal
deleted
inserted
replaced
5573:823aae1ea72a | 5575:d7eaa568da15 |
---|---|
111 { | 111 { |
112 return globalContext_; | 112 return globalContext_; |
113 } | 113 } |
114 } | 114 } |
115 | 115 |
116 | |
117 #if HAS_ORTHANC_PLUGIN_LOG_MESSAGE == 1 | |
116 void LogMessage(OrthancPluginLogLevel level, | 118 void LogMessage(OrthancPluginLogLevel level, |
117 const char* file, | 119 const char* file, |
118 uint32_t line, | 120 uint32_t line, |
119 const std::string& message) | 121 const std::string& message) |
120 { | 122 { |
121 if (HasGlobalContext()) | 123 if (HasGlobalContext()) |
122 { | 124 { |
123 #if ORTHANC_PLUGINS_VERSION_IS_ABOVE(1, 12, 4) | 125 #if HAS_ORTHANC_PLUGIN_LOG_MESSAGE == 1 |
124 const char* pluginName = (pluginName_.empty() ? NULL : pluginName_.c_str()); | 126 const char* pluginName = (pluginName_.empty() ? NULL : pluginName_.c_str()); |
125 OrthancPluginLogMessage(GetGlobalContext(), message.c_str(), pluginName, file, line, OrthancPluginLogCategory_Generic, level); | 127 OrthancPluginLogMessage(GetGlobalContext(), message.c_str(), pluginName, file, line, OrthancPluginLogCategory_Generic, level); |
126 #else | 128 #else |
127 switch (level) | 129 switch (level) |
128 { | 130 { |
142 ORTHANC_PLUGINS_THROW_EXCEPTION(ParameterOutOfRange); | 144 ORTHANC_PLUGINS_THROW_EXCEPTION(ParameterOutOfRange); |
143 } | 145 } |
144 #endif | 146 #endif |
145 } | 147 } |
146 } | 148 } |
149 #endif | |
150 | |
147 | 151 |
148 void LogError(const std::string& message) | 152 void LogError(const std::string& message) |
149 { | 153 { |
150 if (HasGlobalContext()) | 154 if (HasGlobalContext()) |
151 { | 155 { |