comparison Resources/Samples/CppHelpers/Logging/OrthancPluginLogger.cpp @ 3460:fbe22748cd9c

added logging OrthancHelpers
author Alain Mazy <alain@mazy.be>
date Tue, 09 Jul 2019 10:30:30 +0200
parents
children
comparison
equal deleted inserted replaced
3457:9ea218c90057 3460:fbe22748cd9c
1 #include "OrthancPluginLogger.h"
2
3 namespace OrthancHelpers
4 {
5
6 OrthancPluginLogger::OrthancPluginLogger(OrthancPluginContext *context)
7 : pluginContext_(context),
8 hasAlreadyLoggedTraceWarning_(false)
9 {
10 }
11
12 void OrthancPluginLogger::Trace(const char *message)
13 {
14 Trace(std::string(message));
15 }
16
17 void OrthancPluginLogger::Trace(const std::string &message)
18 {
19 if (!hasAlreadyLoggedTraceWarning_)
20 {
21 Warning("Trying to log 'TRACE' level information in a plugin is not possible. These logs won't appear.");
22 hasAlreadyLoggedTraceWarning_ = true;
23 }
24 }
25
26 void OrthancPluginLogger::Info(const char *message)
27 {
28 Info(std::string(message));
29 }
30
31 void OrthancPluginLogger::Info(const std::string &message)
32 {
33 OrthancPluginLogInfo(pluginContext_, (GetContext() + " " + message).c_str());
34 }
35
36 void OrthancPluginLogger::Warning(const char *message)
37 {
38 Warning(std::string(message));
39 }
40
41 void OrthancPluginLogger::Warning(const std::string &message)
42 {
43 OrthancPluginLogWarning(pluginContext_, (GetContext() + " " + message).c_str());
44 }
45
46 void OrthancPluginLogger::Error(const char *message)
47 {
48 Error(std::string(message));
49 }
50
51 void OrthancPluginLogger::Error(const std::string &message)
52 {
53 OrthancPluginLogError(pluginContext_, (GetContext() + " " + message).c_str());
54 }
55 } // namespace OrthancHelpers