annotate OrthancServer/Resources/Samples/CppHelpers/Logging/OrthancPluginLogger.cpp @ 5522:dd430a1b21fe pg-transactions

simplifying StatelessDatabaseOperations
author Sebastien Jodogne <s.jodogne@gmail.com>
date Tue, 30 Jan 2024 09:41:06 +0100
parents 48b8dae6dc77
children f7adfb22e20e
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
4829
c847b0dfd255 added missing copyright headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4044
diff changeset
1 /**
c847b0dfd255 added missing copyright headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4044
diff changeset
2 * Orthanc - A Lightweight, RESTful DICOM Store
c847b0dfd255 added missing copyright headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4044
diff changeset
3 * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics
c847b0dfd255 added missing copyright headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4044
diff changeset
4 * Department, University Hospital of Liege, Belgium
5485
48b8dae6dc77 upgrade to year 2024
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5185
diff changeset
5 * Copyright (C) 2017-2024 Osimis S.A., Belgium
48b8dae6dc77 upgrade to year 2024
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5185
diff changeset
6 * Copyright (C) 2021-2024 Sebastien Jodogne, ICTEAM UCLouvain, Belgium
4829
c847b0dfd255 added missing copyright headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4044
diff changeset
7 *
c847b0dfd255 added missing copyright headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4044
diff changeset
8 * This program is free software: you can redistribute it and/or
c847b0dfd255 added missing copyright headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4044
diff changeset
9 * modify it under the terms of the GNU General Public License as
c847b0dfd255 added missing copyright headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4044
diff changeset
10 * published by the Free Software Foundation, either version 3 of the
c847b0dfd255 added missing copyright headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4044
diff changeset
11 * License, or (at your option) any later version.
c847b0dfd255 added missing copyright headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4044
diff changeset
12 *
c847b0dfd255 added missing copyright headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4044
diff changeset
13 * This program is distributed in the hope that it will be useful, but
c847b0dfd255 added missing copyright headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4044
diff changeset
14 * WITHOUT ANY WARRANTY; without even the implied warranty of
c847b0dfd255 added missing copyright headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4044
diff changeset
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
c847b0dfd255 added missing copyright headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4044
diff changeset
16 * General Public License for more details.
c847b0dfd255 added missing copyright headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4044
diff changeset
17 *
c847b0dfd255 added missing copyright headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4044
diff changeset
18 * You should have received a copy of the GNU General Public License
c847b0dfd255 added missing copyright headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4044
diff changeset
19 * along with this program. If not, see <http://www.gnu.org/licenses/>.
c847b0dfd255 added missing copyright headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4044
diff changeset
20 **/
c847b0dfd255 added missing copyright headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4044
diff changeset
21
c847b0dfd255 added missing copyright headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4044
diff changeset
22
3460
fbe22748cd9c added logging OrthancHelpers
Alain Mazy <alain@mazy.be>
parents:
diff changeset
23 #include "OrthancPluginLogger.h"
fbe22748cd9c added logging OrthancHelpers
Alain Mazy <alain@mazy.be>
parents:
diff changeset
24
fbe22748cd9c added logging OrthancHelpers
Alain Mazy <alain@mazy.be>
parents:
diff changeset
25 namespace OrthancHelpers
fbe22748cd9c added logging OrthancHelpers
Alain Mazy <alain@mazy.be>
parents:
diff changeset
26 {
fbe22748cd9c added logging OrthancHelpers
Alain Mazy <alain@mazy.be>
parents:
diff changeset
27
fbe22748cd9c added logging OrthancHelpers
Alain Mazy <alain@mazy.be>
parents:
diff changeset
28 OrthancPluginLogger::OrthancPluginLogger(OrthancPluginContext *context)
fbe22748cd9c added logging OrthancHelpers
Alain Mazy <alain@mazy.be>
parents:
diff changeset
29 : pluginContext_(context),
fbe22748cd9c added logging OrthancHelpers
Alain Mazy <alain@mazy.be>
parents:
diff changeset
30 hasAlreadyLoggedTraceWarning_(false)
fbe22748cd9c added logging OrthancHelpers
Alain Mazy <alain@mazy.be>
parents:
diff changeset
31 {
fbe22748cd9c added logging OrthancHelpers
Alain Mazy <alain@mazy.be>
parents:
diff changeset
32 }
fbe22748cd9c added logging OrthancHelpers
Alain Mazy <alain@mazy.be>
parents:
diff changeset
33
fbe22748cd9c added logging OrthancHelpers
Alain Mazy <alain@mazy.be>
parents:
diff changeset
34 void OrthancPluginLogger::Trace(const char *message)
fbe22748cd9c added logging OrthancHelpers
Alain Mazy <alain@mazy.be>
parents:
diff changeset
35 {
fbe22748cd9c added logging OrthancHelpers
Alain Mazy <alain@mazy.be>
parents:
diff changeset
36 Trace(std::string(message));
fbe22748cd9c added logging OrthancHelpers
Alain Mazy <alain@mazy.be>
parents:
diff changeset
37 }
fbe22748cd9c added logging OrthancHelpers
Alain Mazy <alain@mazy.be>
parents:
diff changeset
38
fbe22748cd9c added logging OrthancHelpers
Alain Mazy <alain@mazy.be>
parents:
diff changeset
39 void OrthancPluginLogger::Trace(const std::string &message)
fbe22748cd9c added logging OrthancHelpers
Alain Mazy <alain@mazy.be>
parents:
diff changeset
40 {
fbe22748cd9c added logging OrthancHelpers
Alain Mazy <alain@mazy.be>
parents:
diff changeset
41 if (!hasAlreadyLoggedTraceWarning_)
fbe22748cd9c added logging OrthancHelpers
Alain Mazy <alain@mazy.be>
parents:
diff changeset
42 {
fbe22748cd9c added logging OrthancHelpers
Alain Mazy <alain@mazy.be>
parents:
diff changeset
43 Warning("Trying to log 'TRACE' level information in a plugin is not possible. These logs won't appear.");
fbe22748cd9c added logging OrthancHelpers
Alain Mazy <alain@mazy.be>
parents:
diff changeset
44 hasAlreadyLoggedTraceWarning_ = true;
fbe22748cd9c added logging OrthancHelpers
Alain Mazy <alain@mazy.be>
parents:
diff changeset
45 }
fbe22748cd9c added logging OrthancHelpers
Alain Mazy <alain@mazy.be>
parents:
diff changeset
46 }
fbe22748cd9c added logging OrthancHelpers
Alain Mazy <alain@mazy.be>
parents:
diff changeset
47
fbe22748cd9c added logging OrthancHelpers
Alain Mazy <alain@mazy.be>
parents:
diff changeset
48 void OrthancPluginLogger::Info(const char *message)
fbe22748cd9c added logging OrthancHelpers
Alain Mazy <alain@mazy.be>
parents:
diff changeset
49 {
fbe22748cd9c added logging OrthancHelpers
Alain Mazy <alain@mazy.be>
parents:
diff changeset
50 Info(std::string(message));
fbe22748cd9c added logging OrthancHelpers
Alain Mazy <alain@mazy.be>
parents:
diff changeset
51 }
fbe22748cd9c added logging OrthancHelpers
Alain Mazy <alain@mazy.be>
parents:
diff changeset
52
fbe22748cd9c added logging OrthancHelpers
Alain Mazy <alain@mazy.be>
parents:
diff changeset
53 void OrthancPluginLogger::Info(const std::string &message)
fbe22748cd9c added logging OrthancHelpers
Alain Mazy <alain@mazy.be>
parents:
diff changeset
54 {
fbe22748cd9c added logging OrthancHelpers
Alain Mazy <alain@mazy.be>
parents:
diff changeset
55 OrthancPluginLogInfo(pluginContext_, (GetContext() + " " + message).c_str());
fbe22748cd9c added logging OrthancHelpers
Alain Mazy <alain@mazy.be>
parents:
diff changeset
56 }
fbe22748cd9c added logging OrthancHelpers
Alain Mazy <alain@mazy.be>
parents:
diff changeset
57
fbe22748cd9c added logging OrthancHelpers
Alain Mazy <alain@mazy.be>
parents:
diff changeset
58 void OrthancPluginLogger::Warning(const char *message)
fbe22748cd9c added logging OrthancHelpers
Alain Mazy <alain@mazy.be>
parents:
diff changeset
59 {
fbe22748cd9c added logging OrthancHelpers
Alain Mazy <alain@mazy.be>
parents:
diff changeset
60 Warning(std::string(message));
fbe22748cd9c added logging OrthancHelpers
Alain Mazy <alain@mazy.be>
parents:
diff changeset
61 }
fbe22748cd9c added logging OrthancHelpers
Alain Mazy <alain@mazy.be>
parents:
diff changeset
62
fbe22748cd9c added logging OrthancHelpers
Alain Mazy <alain@mazy.be>
parents:
diff changeset
63 void OrthancPluginLogger::Warning(const std::string &message)
fbe22748cd9c added logging OrthancHelpers
Alain Mazy <alain@mazy.be>
parents:
diff changeset
64 {
fbe22748cd9c added logging OrthancHelpers
Alain Mazy <alain@mazy.be>
parents:
diff changeset
65 OrthancPluginLogWarning(pluginContext_, (GetContext() + " " + message).c_str());
fbe22748cd9c added logging OrthancHelpers
Alain Mazy <alain@mazy.be>
parents:
diff changeset
66 }
fbe22748cd9c added logging OrthancHelpers
Alain Mazy <alain@mazy.be>
parents:
diff changeset
67
fbe22748cd9c added logging OrthancHelpers
Alain Mazy <alain@mazy.be>
parents:
diff changeset
68 void OrthancPluginLogger::Error(const char *message)
fbe22748cd9c added logging OrthancHelpers
Alain Mazy <alain@mazy.be>
parents:
diff changeset
69 {
fbe22748cd9c added logging OrthancHelpers
Alain Mazy <alain@mazy.be>
parents:
diff changeset
70 Error(std::string(message));
fbe22748cd9c added logging OrthancHelpers
Alain Mazy <alain@mazy.be>
parents:
diff changeset
71 }
fbe22748cd9c added logging OrthancHelpers
Alain Mazy <alain@mazy.be>
parents:
diff changeset
72
fbe22748cd9c added logging OrthancHelpers
Alain Mazy <alain@mazy.be>
parents:
diff changeset
73 void OrthancPluginLogger::Error(const std::string &message)
fbe22748cd9c added logging OrthancHelpers
Alain Mazy <alain@mazy.be>
parents:
diff changeset
74 {
fbe22748cd9c added logging OrthancHelpers
Alain Mazy <alain@mazy.be>
parents:
diff changeset
75 OrthancPluginLogError(pluginContext_, (GetContext() + " " + message).c_str());
fbe22748cd9c added logging OrthancHelpers
Alain Mazy <alain@mazy.be>
parents:
diff changeset
76 }
fbe22748cd9c added logging OrthancHelpers
Alain Mazy <alain@mazy.be>
parents:
diff changeset
77 } // namespace OrthancHelpers