Mercurial > hg > orthanc-stone
comparison Resources/Orthanc/Core/Logging.cpp @ 40:7207a407bcd8
shared copyright with osimis
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Wed, 04 Jan 2017 16:37:42 +0100 |
parents | ff1e935768e7 |
children | 81e2651dca17 |
comparison
equal
deleted
inserted
replaced
39:9ee7e2f5f1a3 | 40:7207a407bcd8 |
---|---|
1 /** | 1 /** |
2 * Orthanc - A Lightweight, RESTful DICOM Store | 2 * Orthanc - A Lightweight, RESTful DICOM Store |
3 * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics | 3 * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics |
4 * Department, University Hospital of Liege, Belgium | 4 * Department, University Hospital of Liege, Belgium |
5 * Copyright (C) 2017 Osimis, Belgium | |
5 * | 6 * |
6 * This program is free software: you can redistribute it and/or | 7 * This program is free software: you can redistribute it and/or |
7 * modify it under the terms of the GNU General Public License as | 8 * modify it under the terms of the GNU General Public License as |
8 * published by the Free Software Foundation, either version 3 of the | 9 * published by the Free Software Foundation, either version 3 of the |
9 * License, or (at your option) any later version. | 10 * License, or (at your option) any later version. |
71 { | 72 { |
72 } | 73 } |
73 } | 74 } |
74 } | 75 } |
75 | 76 |
76 #else | 77 |
78 #elif ORTHANC_ENABLE_LOGGING_PLUGIN == 1 | |
79 | |
80 /********************************************************* | |
81 * Logger compatible with the Orthanc plugin SDK | |
82 *********************************************************/ | |
83 | |
84 #include <boost/lexical_cast.hpp> | |
85 | |
86 namespace Orthanc | |
87 { | |
88 namespace Logging | |
89 { | |
90 static OrthancPluginContext* context_ = NULL; | |
91 | |
92 void Initialize(OrthancPluginContext* context) | |
93 { | |
94 context_ = context_; | |
95 } | |
96 | |
97 InternalLogger::InternalLogger(const char* level, | |
98 const char* file /* ignored */, | |
99 int line /* ignored */) : | |
100 level_(level) | |
101 { | |
102 } | |
103 | |
104 InternalLogger::~InternalLogger() | |
105 { | |
106 if (context_ != NULL) | |
107 { | |
108 if (level_ == "ERROR") | |
109 { | |
110 OrthancPluginLogError(context_, message_.c_str()); | |
111 } | |
112 else if (level_ == "WARNING") | |
113 { | |
114 OrthancPluginLogWarning(context_, message_.c_str()); | |
115 } | |
116 else if (level_ == "INFO") | |
117 { | |
118 OrthancPluginLogInfo(context_, message_.c_str()); | |
119 } | |
120 } | |
121 } | |
122 | |
123 InternalLogger& InternalLogger::operator<< (const std::string& message) | |
124 { | |
125 message_ += message; | |
126 return *this; | |
127 } | |
128 | |
129 InternalLogger& InternalLogger::operator<< (const char* message) | |
130 { | |
131 message_ += std::string(message); | |
132 return *this; | |
133 } | |
134 | |
135 InternalLogger& InternalLogger::operator<< (int message) | |
136 { | |
137 message_ += boost::lexical_cast<std::string>(message); | |
138 return *this; | |
139 } | |
140 } | |
141 } | |
142 | |
143 | |
144 #else /* ORTHANC_ENABLE_LOGGING_PLUGIN == 0 && ORTHANC_ENABLE_LOGGING == 1 */ | |
77 | 145 |
78 /********************************************************* | 146 /********************************************************* |
79 * Internal logger of Orthanc, that mimics some | 147 * Internal logger of Orthanc, that mimics some |
80 * behavior from Google Log. | 148 * behavior from Google Log. |
81 *********************************************************/ | 149 *********************************************************/ |