annotate OrthancFramework/UnitTestsSources/LoggingTests.cpp @ 5264:99751c5a7cfe

added missing copyrights
author Sebastien Jodogne <s.jodogne@gmail.com>
date Wed, 12 Apr 2023 17:43:05 +0200
parents 0ea402b4d901
children d7c9c85d78dc
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
3353
54cdad5a7228 Added a public function that will use emscripten-specific logging functions when using its SDK + scaffolding work. Build and UT OK on msvc15 x64. Not actually tested under *nix or emscripten yet
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
1 /**
54cdad5a7228 Added a public function that will use emscripten-specific logging functions when using its SDK + scaffolding work. Build and UT OK on msvc15 x64. Not actually tested under *nix or emscripten yet
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
2 * Orthanc - A Lightweight, RESTful DICOM Store
54cdad5a7228 Added a public function that will use emscripten-specific logging functions when using its SDK + scaffolding work. Build and UT OK on msvc15 x64. Not actually tested under *nix or emscripten yet
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
3 * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics
54cdad5a7228 Added a public function that will use emscripten-specific logging functions when using its SDK + scaffolding work. Build and UT OK on msvc15 x64. Not actually tested under *nix or emscripten yet
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
4 * Department, University Hospital of Liege, Belgium
5185
0ea402b4d901 upgrade to year 2023
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4870
diff changeset
5 * Copyright (C) 2017-2023 Osimis S.A., Belgium
0ea402b4d901 upgrade to year 2023
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4870
diff changeset
6 * Copyright (C) 2021-2023 Sebastien Jodogne, ICTEAM UCLouvain, Belgium
3353
54cdad5a7228 Added a public function that will use emscripten-specific logging functions when using its SDK + scaffolding work. Build and UT OK on msvc15 x64. Not actually tested under *nix or emscripten yet
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
7 *
54cdad5a7228 Added a public function that will use emscripten-specific logging functions when using its SDK + scaffolding work. Build and UT OK on msvc15 x64. Not actually tested under *nix or emscripten yet
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
8 * This program is free software: you can redistribute it and/or
4119
bf7b9edf6b81 re-licensing the OrthancFramework to LGPL, in order to license Stone of Orthanc under LGPL
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4063
diff changeset
9 * modify it under the terms of the GNU Lesser General Public License
bf7b9edf6b81 re-licensing the OrthancFramework to LGPL, in order to license Stone of Orthanc under LGPL
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4063
diff changeset
10 * as published by the Free Software Foundation, either version 3 of
bf7b9edf6b81 re-licensing the OrthancFramework to LGPL, in order to license Stone of Orthanc under LGPL
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4063
diff changeset
11 * the License, or (at your option) any later version.
3353
54cdad5a7228 Added a public function that will use emscripten-specific logging functions when using its SDK + scaffolding work. Build and UT OK on msvc15 x64. Not actually tested under *nix or emscripten yet
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
12 *
54cdad5a7228 Added a public function that will use emscripten-specific logging functions when using its SDK + scaffolding work. Build and UT OK on msvc15 x64. Not actually tested under *nix or emscripten yet
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
13 * This program is distributed in the hope that it will be useful, but
54cdad5a7228 Added a public function that will use emscripten-specific logging functions when using its SDK + scaffolding work. Build and UT OK on msvc15 x64. Not actually tested under *nix or emscripten yet
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
14 * WITHOUT ANY WARRANTY; without even the implied warranty of
54cdad5a7228 Added a public function that will use emscripten-specific logging functions when using its SDK + scaffolding work. Build and UT OK on msvc15 x64. Not actually tested under *nix or emscripten yet
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
4119
bf7b9edf6b81 re-licensing the OrthancFramework to LGPL, in order to license Stone of Orthanc under LGPL
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4063
diff changeset
16 * Lesser General Public License for more details.
3353
54cdad5a7228 Added a public function that will use emscripten-specific logging functions when using its SDK + scaffolding work. Build and UT OK on msvc15 x64. Not actually tested under *nix or emscripten yet
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
17 *
4119
bf7b9edf6b81 re-licensing the OrthancFramework to LGPL, in order to license Stone of Orthanc under LGPL
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4063
diff changeset
18 * You should have received a copy of the GNU Lesser General Public
bf7b9edf6b81 re-licensing the OrthancFramework to LGPL, in order to license Stone of Orthanc under LGPL
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4063
diff changeset
19 * License along with this program. If not, see
bf7b9edf6b81 re-licensing the OrthancFramework to LGPL, in order to license Stone of Orthanc under LGPL
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4063
diff changeset
20 * <http://www.gnu.org/licenses/>.
3353
54cdad5a7228 Added a public function that will use emscripten-specific logging functions when using its SDK + scaffolding work. Build and UT OK on msvc15 x64. Not actually tested under *nix or emscripten yet
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
21 **/
54cdad5a7228 Added a public function that will use emscripten-specific logging functions when using its SDK + scaffolding work. Build and UT OK on msvc15 x64. Not actually tested under *nix or emscripten yet
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
22
3992
f9863630ec7f working on the shared library for Orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
23
f9863630ec7f working on the shared library for Orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
24 #if ORTHANC_UNIT_TESTS_LINK_FRAMEWORK == 1
4063
e00f3d089991 shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4062
diff changeset
25 // Must be the first to be sure to use the Orthanc framework shared library
4014
27628b0f6ada merging logging code for plugins and files
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4008
diff changeset
26 # include <OrthancFramework.h>
3992
f9863630ec7f working on the shared library for Orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
27 #endif
f9863630ec7f working on the shared library for Orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
28
4062
0953b3dc3261 pretty-printing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4045
diff changeset
29 #include <gtest/gtest.h>
0953b3dc3261 pretty-printing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4045
diff changeset
30
0953b3dc3261 pretty-printing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4045
diff changeset
31 #include "../Sources/Logging.h"
4270
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
32 #include "../Sources/OrthancException.h"
4062
0953b3dc3261 pretty-printing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4045
diff changeset
33
3353
54cdad5a7228 Added a public function that will use emscripten-specific logging functions when using its SDK + scaffolding work. Build and UT OK on msvc15 x64. Not actually tested under *nix or emscripten yet
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
34 #include <boost/regex.hpp>
54cdad5a7228 Added a public function that will use emscripten-specific logging functions when using its SDK + scaffolding work. Build and UT OK on msvc15 x64. Not actually tested under *nix or emscripten yet
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
35 #include <sstream>
54cdad5a7228 Added a public function that will use emscripten-specific logging functions when using its SDK + scaffolding work. Build and UT OK on msvc15 x64. Not actually tested under *nix or emscripten yet
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
36
54cdad5a7228 Added a public function that will use emscripten-specific logging functions when using its SDK + scaffolding work. Build and UT OK on msvc15 x64. Not actually tested under *nix or emscripten yet
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
37
54cdad5a7228 Added a public function that will use emscripten-specific logging functions when using its SDK + scaffolding work. Build and UT OK on msvc15 x64. Not actually tested under *nix or emscripten yet
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
38 static std::stringstream testErrorStream;
54cdad5a7228 Added a public function that will use emscripten-specific logging functions when using its SDK + scaffolding work. Build and UT OK on msvc15 x64. Not actually tested under *nix or emscripten yet
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
39 void TestError(const char* message)
54cdad5a7228 Added a public function that will use emscripten-specific logging functions when using its SDK + scaffolding work. Build and UT OK on msvc15 x64. Not actually tested under *nix or emscripten yet
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
40 {
54cdad5a7228 Added a public function that will use emscripten-specific logging functions when using its SDK + scaffolding work. Build and UT OK on msvc15 x64. Not actually tested under *nix or emscripten yet
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
41 testErrorStream << message;
54cdad5a7228 Added a public function that will use emscripten-specific logging functions when using its SDK + scaffolding work. Build and UT OK on msvc15 x64. Not actually tested under *nix or emscripten yet
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
42 }
54cdad5a7228 Added a public function that will use emscripten-specific logging functions when using its SDK + scaffolding work. Build and UT OK on msvc15 x64. Not actually tested under *nix or emscripten yet
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
43
54cdad5a7228 Added a public function that will use emscripten-specific logging functions when using its SDK + scaffolding work. Build and UT OK on msvc15 x64. Not actually tested under *nix or emscripten yet
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
44 static std::stringstream testWarningStream;
54cdad5a7228 Added a public function that will use emscripten-specific logging functions when using its SDK + scaffolding work. Build and UT OK on msvc15 x64. Not actually tested under *nix or emscripten yet
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
45 void TestWarning(const char* message)
54cdad5a7228 Added a public function that will use emscripten-specific logging functions when using its SDK + scaffolding work. Build and UT OK on msvc15 x64. Not actually tested under *nix or emscripten yet
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
46 {
54cdad5a7228 Added a public function that will use emscripten-specific logging functions when using its SDK + scaffolding work. Build and UT OK on msvc15 x64. Not actually tested under *nix or emscripten yet
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
47 testWarningStream << message;
54cdad5a7228 Added a public function that will use emscripten-specific logging functions when using its SDK + scaffolding work. Build and UT OK on msvc15 x64. Not actually tested under *nix or emscripten yet
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
48 }
54cdad5a7228 Added a public function that will use emscripten-specific logging functions when using its SDK + scaffolding work. Build and UT OK on msvc15 x64. Not actually tested under *nix or emscripten yet
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
49
54cdad5a7228 Added a public function that will use emscripten-specific logging functions when using its SDK + scaffolding work. Build and UT OK on msvc15 x64. Not actually tested under *nix or emscripten yet
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
50 static std::stringstream testInfoStream;
54cdad5a7228 Added a public function that will use emscripten-specific logging functions when using its SDK + scaffolding work. Build and UT OK on msvc15 x64. Not actually tested under *nix or emscripten yet
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
51 void TestInfo(const char* message)
54cdad5a7228 Added a public function that will use emscripten-specific logging functions when using its SDK + scaffolding work. Build and UT OK on msvc15 x64. Not actually tested under *nix or emscripten yet
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
52 {
54cdad5a7228 Added a public function that will use emscripten-specific logging functions when using its SDK + scaffolding work. Build and UT OK on msvc15 x64. Not actually tested under *nix or emscripten yet
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
53 testInfoStream << message;
54cdad5a7228 Added a public function that will use emscripten-specific logging functions when using its SDK + scaffolding work. Build and UT OK on msvc15 x64. Not actually tested under *nix or emscripten yet
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
54 }
54cdad5a7228 Added a public function that will use emscripten-specific logging functions when using its SDK + scaffolding work. Build and UT OK on msvc15 x64. Not actually tested under *nix or emscripten yet
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
55
54cdad5a7228 Added a public function that will use emscripten-specific logging functions when using its SDK + scaffolding work. Build and UT OK on msvc15 x64. Not actually tested under *nix or emscripten yet
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
56 /**
4008
2d4427ca4be9 removed Core/LoggingUtils.h
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4004
diff changeset
57 Extracts the log line payload
3353
54cdad5a7228 Added a public function that will use emscripten-specific logging functions when using its SDK + scaffolding work. Build and UT OK on msvc15 x64. Not actually tested under *nix or emscripten yet
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
58
4008
2d4427ca4be9 removed Core/LoggingUtils.h
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4004
diff changeset
59 "E0423 16:55:43.001194 LoggingTests.cpp:102] Foo bar?\n"
2d4427ca4be9 removed Core/LoggingUtils.h
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4004
diff changeset
60 -->
2d4427ca4be9 removed Core/LoggingUtils.h
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4004
diff changeset
61 "Foo bar"
3353
54cdad5a7228 Added a public function that will use emscripten-specific logging functions when using its SDK + scaffolding work. Build and UT OK on msvc15 x64. Not actually tested under *nix or emscripten yet
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
62
4008
2d4427ca4be9 removed Core/LoggingUtils.h
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4004
diff changeset
63 If the log line cannot be matched, the function returns false.
3353
54cdad5a7228 Added a public function that will use emscripten-specific logging functions when using its SDK + scaffolding work. Build and UT OK on msvc15 x64. Not actually tested under *nix or emscripten yet
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
64 */
3359
815b81142ff7 Enable custom logging functions to redirect to emscripten specific logging calls
Benjamin Golinvaux <bgo@osimis.io>
parents: 3353
diff changeset
65
3471
1fdbe5885783 fix unit tests: removed \r from the expected string since we removed it when generating the log line
Alain Mazy <alain@mazy.be>
parents: 3359
diff changeset
66 #define EOLSTRING "\n"
3359
815b81142ff7 Enable custom logging functions to redirect to emscripten specific logging calls
Benjamin Golinvaux <bgo@osimis.io>
parents: 3353
diff changeset
67
3353
54cdad5a7228 Added a public function that will use emscripten-specific logging functions when using its SDK + scaffolding work. Build and UT OK on msvc15 x64. Not actually tested under *nix or emscripten yet
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
68 static bool GetLogLinePayload(std::string& payload,
4008
2d4427ca4be9 removed Core/LoggingUtils.h
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4004
diff changeset
69 const std::string& logLine)
3353
54cdad5a7228 Added a public function that will use emscripten-specific logging functions when using its SDK + scaffolding work. Build and UT OK on msvc15 x64. Not actually tested under *nix or emscripten yet
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
70 {
54cdad5a7228 Added a public function that will use emscripten-specific logging functions when using its SDK + scaffolding work. Build and UT OK on msvc15 x64. Not actually tested under *nix or emscripten yet
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
71 const char* regexStr = "[A-Z][0-9]{4} [0-9]{2}:[0-9]{2}:[0-9]{2}.[0-9]{6} "
3359
815b81142ff7 Enable custom logging functions to redirect to emscripten specific logging calls
Benjamin Golinvaux <bgo@osimis.io>
parents: 3353
diff changeset
72 "[a-zA-Z\\.\\-_]+:[0-9]+\\] (.*)" EOLSTRING "$";
815b81142ff7 Enable custom logging functions to redirect to emscripten specific logging calls
Benjamin Golinvaux <bgo@osimis.io>
parents: 3353
diff changeset
73
3353
54cdad5a7228 Added a public function that will use emscripten-specific logging functions when using its SDK + scaffolding work. Build and UT OK on msvc15 x64. Not actually tested under *nix or emscripten yet
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
74 boost::regex regexObj(regexStr);
54cdad5a7228 Added a public function that will use emscripten-specific logging functions when using its SDK + scaffolding work. Build and UT OK on msvc15 x64. Not actually tested under *nix or emscripten yet
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
75
54cdad5a7228 Added a public function that will use emscripten-specific logging functions when using its SDK + scaffolding work. Build and UT OK on msvc15 x64. Not actually tested under *nix or emscripten yet
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
76 //std::stringstream regexSStr;
54cdad5a7228 Added a public function that will use emscripten-specific logging functions when using its SDK + scaffolding work. Build and UT OK on msvc15 x64. Not actually tested under *nix or emscripten yet
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
77 //regexSStr << "E[0-9]{4} [0-9]{2}:[0-9]{2}:[0-9]{2}.[0-9]{6} "
54cdad5a7228 Added a public function that will use emscripten-specific logging functions when using its SDK + scaffolding work. Build and UT OK on msvc15 x64. Not actually tested under *nix or emscripten yet
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
78 // "[a-zA-Z\\.\\-_]+:[0-9]+\\](.*)\r\n$";
54cdad5a7228 Added a public function that will use emscripten-specific logging functions when using its SDK + scaffolding work. Build and UT OK on msvc15 x64. Not actually tested under *nix or emscripten yet
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
79 //std::string regexStr = regexSStr.str();
54cdad5a7228 Added a public function that will use emscripten-specific logging functions when using its SDK + scaffolding work. Build and UT OK on msvc15 x64. Not actually tested under *nix or emscripten yet
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
80 boost::regex pattern(regexStr);
54cdad5a7228 Added a public function that will use emscripten-specific logging functions when using its SDK + scaffolding work. Build and UT OK on msvc15 x64. Not actually tested under *nix or emscripten yet
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
81 boost::cmatch what;
54cdad5a7228 Added a public function that will use emscripten-specific logging functions when using its SDK + scaffolding work. Build and UT OK on msvc15 x64. Not actually tested under *nix or emscripten yet
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
82 if (regex_match(logLine.c_str(), what, regexObj))
54cdad5a7228 Added a public function that will use emscripten-specific logging functions when using its SDK + scaffolding work. Build and UT OK on msvc15 x64. Not actually tested under *nix or emscripten yet
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
83 {
54cdad5a7228 Added a public function that will use emscripten-specific logging functions when using its SDK + scaffolding work. Build and UT OK on msvc15 x64. Not actually tested under *nix or emscripten yet
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
84 payload = what[1];
54cdad5a7228 Added a public function that will use emscripten-specific logging functions when using its SDK + scaffolding work. Build and UT OK on msvc15 x64. Not actually tested under *nix or emscripten yet
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
85 return true;
54cdad5a7228 Added a public function that will use emscripten-specific logging functions when using its SDK + scaffolding work. Build and UT OK on msvc15 x64. Not actually tested under *nix or emscripten yet
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
86 }
54cdad5a7228 Added a public function that will use emscripten-specific logging functions when using its SDK + scaffolding work. Build and UT OK on msvc15 x64. Not actually tested under *nix or emscripten yet
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
87 else
54cdad5a7228 Added a public function that will use emscripten-specific logging functions when using its SDK + scaffolding work. Build and UT OK on msvc15 x64. Not actually tested under *nix or emscripten yet
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
88 {
54cdad5a7228 Added a public function that will use emscripten-specific logging functions when using its SDK + scaffolding work. Build and UT OK on msvc15 x64. Not actually tested under *nix or emscripten yet
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
89 return false;
54cdad5a7228 Added a public function that will use emscripten-specific logging functions when using its SDK + scaffolding work. Build and UT OK on msvc15 x64. Not actually tested under *nix or emscripten yet
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
90 }
54cdad5a7228 Added a public function that will use emscripten-specific logging functions when using its SDK + scaffolding work. Build and UT OK on msvc15 x64. Not actually tested under *nix or emscripten yet
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
91 }
54cdad5a7228 Added a public function that will use emscripten-specific logging functions when using its SDK + scaffolding work. Build and UT OK on msvc15 x64. Not actually tested under *nix or emscripten yet
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
92
4008
2d4427ca4be9 removed Core/LoggingUtils.h
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4004
diff changeset
93
3353
54cdad5a7228 Added a public function that will use emscripten-specific logging functions when using its SDK + scaffolding work. Build and UT OK on msvc15 x64. Not actually tested under *nix or emscripten yet
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
94 namespace
54cdad5a7228 Added a public function that will use emscripten-specific logging functions when using its SDK + scaffolding work. Build and UT OK on msvc15 x64. Not actually tested under *nix or emscripten yet
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
95 {
54cdad5a7228 Added a public function that will use emscripten-specific logging functions when using its SDK + scaffolding work. Build and UT OK on msvc15 x64. Not actually tested under *nix or emscripten yet
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
96 class LoggingMementoScope
54cdad5a7228 Added a public function that will use emscripten-specific logging functions when using its SDK + scaffolding work. Build and UT OK on msvc15 x64. Not actually tested under *nix or emscripten yet
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
97 {
54cdad5a7228 Added a public function that will use emscripten-specific logging functions when using its SDK + scaffolding work. Build and UT OK on msvc15 x64. Not actually tested under *nix or emscripten yet
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
98 public:
4003
3c19371090c3 removing useless LoggingMemento
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3992
diff changeset
99 LoggingMementoScope()
3c19371090c3 removing useless LoggingMemento
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3992
diff changeset
100 {
3c19371090c3 removing useless LoggingMemento
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3992
diff changeset
101 }
3c19371090c3 removing useless LoggingMemento
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3992
diff changeset
102
3353
54cdad5a7228 Added a public function that will use emscripten-specific logging functions when using its SDK + scaffolding work. Build and UT OK on msvc15 x64. Not actually tested under *nix or emscripten yet
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
103 ~LoggingMementoScope()
54cdad5a7228 Added a public function that will use emscripten-specific logging functions when using its SDK + scaffolding work. Build and UT OK on msvc15 x64. Not actually tested under *nix or emscripten yet
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
104 {
4003
3c19371090c3 removing useless LoggingMemento
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3992
diff changeset
105 Orthanc::Logging::Reset();
3353
54cdad5a7228 Added a public function that will use emscripten-specific logging functions when using its SDK + scaffolding work. Build and UT OK on msvc15 x64. Not actually tested under *nix or emscripten yet
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
106 }
54cdad5a7228 Added a public function that will use emscripten-specific logging functions when using its SDK + scaffolding work. Build and UT OK on msvc15 x64. Not actually tested under *nix or emscripten yet
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
107 };
4008
2d4427ca4be9 removed Core/LoggingUtils.h
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4004
diff changeset
108
2d4427ca4be9 removed Core/LoggingUtils.h
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4004
diff changeset
109
2d4427ca4be9 removed Core/LoggingUtils.h
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4004
diff changeset
110 /**
2d4427ca4be9 removed Core/LoggingUtils.h
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4004
diff changeset
111 * std::streambuf subclass used in FunctionCallingStream
2d4427ca4be9 removed Core/LoggingUtils.h
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4004
diff changeset
112 **/
2d4427ca4be9 removed Core/LoggingUtils.h
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4004
diff changeset
113 template<typename T>
2d4427ca4be9 removed Core/LoggingUtils.h
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4004
diff changeset
114 class FuncStreamBuf : public std::stringbuf
2d4427ca4be9 removed Core/LoggingUtils.h
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4004
diff changeset
115 {
2d4427ca4be9 removed Core/LoggingUtils.h
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4004
diff changeset
116 public:
4204
318c16cfccab cppcheck
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4119
diff changeset
117 explicit FuncStreamBuf(T func) : func_(func) {}
4008
2d4427ca4be9 removed Core/LoggingUtils.h
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4004
diff changeset
118
2d4427ca4be9 removed Core/LoggingUtils.h
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4004
diff changeset
119 virtual int sync()
2d4427ca4be9 removed Core/LoggingUtils.h
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4004
diff changeset
120 {
2d4427ca4be9 removed Core/LoggingUtils.h
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4004
diff changeset
121 std::string text = this->str();
2d4427ca4be9 removed Core/LoggingUtils.h
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4004
diff changeset
122 const char* buf = text.c_str();
2d4427ca4be9 removed Core/LoggingUtils.h
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4004
diff changeset
123 func_(buf);
2d4427ca4be9 removed Core/LoggingUtils.h
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4004
diff changeset
124 this->str("");
2d4427ca4be9 removed Core/LoggingUtils.h
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4004
diff changeset
125 return 0;
2d4427ca4be9 removed Core/LoggingUtils.h
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4004
diff changeset
126 }
2d4427ca4be9 removed Core/LoggingUtils.h
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4004
diff changeset
127 private:
2d4427ca4be9 removed Core/LoggingUtils.h
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4004
diff changeset
128 T func_;
2d4427ca4be9 removed Core/LoggingUtils.h
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4004
diff changeset
129 };
3353
54cdad5a7228 Added a public function that will use emscripten-specific logging functions when using its SDK + scaffolding work. Build and UT OK on msvc15 x64. Not actually tested under *nix or emscripten yet
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
130 }
54cdad5a7228 Added a public function that will use emscripten-specific logging functions when using its SDK + scaffolding work. Build and UT OK on msvc15 x64. Not actually tested under *nix or emscripten yet
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
131
4008
2d4427ca4be9 removed Core/LoggingUtils.h
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4004
diff changeset
132
4325
b96aedfa8cc1 unit tests now running in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4299
diff changeset
133 #if ORTHANC_ENABLE_LOGGING_STDIO == 0
3353
54cdad5a7228 Added a public function that will use emscripten-specific logging functions when using its SDK + scaffolding work. Build and UT OK on msvc15 x64. Not actually tested under *nix or emscripten yet
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
134 TEST(FuncStreamBuf, BasicTest)
54cdad5a7228 Added a public function that will use emscripten-specific logging functions when using its SDK + scaffolding work. Build and UT OK on msvc15 x64. Not actually tested under *nix or emscripten yet
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
135 {
54cdad5a7228 Added a public function that will use emscripten-specific logging functions when using its SDK + scaffolding work. Build and UT OK on msvc15 x64. Not actually tested under *nix or emscripten yet
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
136 LoggingMementoScope loggingConfiguration;
54cdad5a7228 Added a public function that will use emscripten-specific logging functions when using its SDK + scaffolding work. Build and UT OK on msvc15 x64. Not actually tested under *nix or emscripten yet
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
137
4270
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
138 Orthanc::Logging::EnableTraceLevel(true);
3353
54cdad5a7228 Added a public function that will use emscripten-specific logging functions when using its SDK + scaffolding work. Build and UT OK on msvc15 x64. Not actually tested under *nix or emscripten yet
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
139
54cdad5a7228 Added a public function that will use emscripten-specific logging functions when using its SDK + scaffolding work. Build and UT OK on msvc15 x64. Not actually tested under *nix or emscripten yet
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
140 typedef void(*LoggingFunctionFunc)(const char*);
54cdad5a7228 Added a public function that will use emscripten-specific logging functions when using its SDK + scaffolding work. Build and UT OK on msvc15 x64. Not actually tested under *nix or emscripten yet
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
141
54cdad5a7228 Added a public function that will use emscripten-specific logging functions when using its SDK + scaffolding work. Build and UT OK on msvc15 x64. Not actually tested under *nix or emscripten yet
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
142 FuncStreamBuf<LoggingFunctionFunc> errorStreamBuf(TestError);
54cdad5a7228 Added a public function that will use emscripten-specific logging functions when using its SDK + scaffolding work. Build and UT OK on msvc15 x64. Not actually tested under *nix or emscripten yet
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
143 std::ostream errorStream(&errorStreamBuf);
54cdad5a7228 Added a public function that will use emscripten-specific logging functions when using its SDK + scaffolding work. Build and UT OK on msvc15 x64. Not actually tested under *nix or emscripten yet
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
144
54cdad5a7228 Added a public function that will use emscripten-specific logging functions when using its SDK + scaffolding work. Build and UT OK on msvc15 x64. Not actually tested under *nix or emscripten yet
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
145 FuncStreamBuf<LoggingFunctionFunc> warningStreamBuf(TestWarning);
54cdad5a7228 Added a public function that will use emscripten-specific logging functions when using its SDK + scaffolding work. Build and UT OK on msvc15 x64. Not actually tested under *nix or emscripten yet
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
146 std::ostream warningStream(&warningStreamBuf);
54cdad5a7228 Added a public function that will use emscripten-specific logging functions when using its SDK + scaffolding work. Build and UT OK on msvc15 x64. Not actually tested under *nix or emscripten yet
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
147
54cdad5a7228 Added a public function that will use emscripten-specific logging functions when using its SDK + scaffolding work. Build and UT OK on msvc15 x64. Not actually tested under *nix or emscripten yet
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
148 FuncStreamBuf<LoggingFunctionFunc> infoStreamBuf(TestInfo);
54cdad5a7228 Added a public function that will use emscripten-specific logging functions when using its SDK + scaffolding work. Build and UT OK on msvc15 x64. Not actually tested under *nix or emscripten yet
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
149 std::ostream infoStream(&infoStreamBuf);
54cdad5a7228 Added a public function that will use emscripten-specific logging functions when using its SDK + scaffolding work. Build and UT OK on msvc15 x64. Not actually tested under *nix or emscripten yet
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
150
4270
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
151 Orthanc::Logging::SetErrorWarnInfoLoggingStreams(errorStream, warningStream, infoStream);
3353
54cdad5a7228 Added a public function that will use emscripten-specific logging functions when using its SDK + scaffolding work. Build and UT OK on msvc15 x64. Not actually tested under *nix or emscripten yet
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
152
54cdad5a7228 Added a public function that will use emscripten-specific logging functions when using its SDK + scaffolding work. Build and UT OK on msvc15 x64. Not actually tested under *nix or emscripten yet
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
153 {
54cdad5a7228 Added a public function that will use emscripten-specific logging functions when using its SDK + scaffolding work. Build and UT OK on msvc15 x64. Not actually tested under *nix or emscripten yet
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
154 const char* text = "E is the set of all sets that do not contain themselves. Does E contain itself?";
54cdad5a7228 Added a public function that will use emscripten-specific logging functions when using its SDK + scaffolding work. Build and UT OK on msvc15 x64. Not actually tested under *nix or emscripten yet
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
155 LOG(ERROR) << text;
54cdad5a7228 Added a public function that will use emscripten-specific logging functions when using its SDK + scaffolding work. Build and UT OK on msvc15 x64. Not actually tested under *nix or emscripten yet
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
156 std::string logLine = testErrorStream.str();
54cdad5a7228 Added a public function that will use emscripten-specific logging functions when using its SDK + scaffolding work. Build and UT OK on msvc15 x64. Not actually tested under *nix or emscripten yet
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
157 testErrorStream.str("");
54cdad5a7228 Added a public function that will use emscripten-specific logging functions when using its SDK + scaffolding work. Build and UT OK on msvc15 x64. Not actually tested under *nix or emscripten yet
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
158 testErrorStream.clear();
54cdad5a7228 Added a public function that will use emscripten-specific logging functions when using its SDK + scaffolding work. Build and UT OK on msvc15 x64. Not actually tested under *nix or emscripten yet
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
159 std::string payload;
54cdad5a7228 Added a public function that will use emscripten-specific logging functions when using its SDK + scaffolding work. Build and UT OK on msvc15 x64. Not actually tested under *nix or emscripten yet
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
160 bool ok = GetLogLinePayload(payload, logLine);
3359
815b81142ff7 Enable custom logging functions to redirect to emscripten specific logging calls
Benjamin Golinvaux <bgo@osimis.io>
parents: 3353
diff changeset
161 ASSERT_TRUE(ok);
3353
54cdad5a7228 Added a public function that will use emscripten-specific logging functions when using its SDK + scaffolding work. Build and UT OK on msvc15 x64. Not actually tested under *nix or emscripten yet
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
162 ASSERT_STREQ(payload.c_str(), text);
54cdad5a7228 Added a public function that will use emscripten-specific logging functions when using its SDK + scaffolding work. Build and UT OK on msvc15 x64. Not actually tested under *nix or emscripten yet
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
163 }
54cdad5a7228 Added a public function that will use emscripten-specific logging functions when using its SDK + scaffolding work. Build and UT OK on msvc15 x64. Not actually tested under *nix or emscripten yet
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
164
54cdad5a7228 Added a public function that will use emscripten-specific logging functions when using its SDK + scaffolding work. Build and UT OK on msvc15 x64. Not actually tested under *nix or emscripten yet
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
165 // make sure loglines do not accumulate
54cdad5a7228 Added a public function that will use emscripten-specific logging functions when using its SDK + scaffolding work. Build and UT OK on msvc15 x64. Not actually tested under *nix or emscripten yet
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
166 {
54cdad5a7228 Added a public function that will use emscripten-specific logging functions when using its SDK + scaffolding work. Build and UT OK on msvc15 x64. Not actually tested under *nix or emscripten yet
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
167 const char* text = "some more nonsensical babblingiciously stupid gibberish";
54cdad5a7228 Added a public function that will use emscripten-specific logging functions when using its SDK + scaffolding work. Build and UT OK on msvc15 x64. Not actually tested under *nix or emscripten yet
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
168 LOG(ERROR) << text;
54cdad5a7228 Added a public function that will use emscripten-specific logging functions when using its SDK + scaffolding work. Build and UT OK on msvc15 x64. Not actually tested under *nix or emscripten yet
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
169 std::string logLine = testErrorStream.str();
54cdad5a7228 Added a public function that will use emscripten-specific logging functions when using its SDK + scaffolding work. Build and UT OK on msvc15 x64. Not actually tested under *nix or emscripten yet
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
170 testErrorStream.str("");
54cdad5a7228 Added a public function that will use emscripten-specific logging functions when using its SDK + scaffolding work. Build and UT OK on msvc15 x64. Not actually tested under *nix or emscripten yet
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
171 testErrorStream.clear();
54cdad5a7228 Added a public function that will use emscripten-specific logging functions when using its SDK + scaffolding work. Build and UT OK on msvc15 x64. Not actually tested under *nix or emscripten yet
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
172 std::string payload;
54cdad5a7228 Added a public function that will use emscripten-specific logging functions when using its SDK + scaffolding work. Build and UT OK on msvc15 x64. Not actually tested under *nix or emscripten yet
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
173 bool ok = GetLogLinePayload(payload, logLine);
3359
815b81142ff7 Enable custom logging functions to redirect to emscripten specific logging calls
Benjamin Golinvaux <bgo@osimis.io>
parents: 3353
diff changeset
174 ASSERT_TRUE(ok);
3353
54cdad5a7228 Added a public function that will use emscripten-specific logging functions when using its SDK + scaffolding work. Build and UT OK on msvc15 x64. Not actually tested under *nix or emscripten yet
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
175 ASSERT_STREQ(payload.c_str(), text);
54cdad5a7228 Added a public function that will use emscripten-specific logging functions when using its SDK + scaffolding work. Build and UT OK on msvc15 x64. Not actually tested under *nix or emscripten yet
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
176 }
54cdad5a7228 Added a public function that will use emscripten-specific logging functions when using its SDK + scaffolding work. Build and UT OK on msvc15 x64. Not actually tested under *nix or emscripten yet
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
177
54cdad5a7228 Added a public function that will use emscripten-specific logging functions when using its SDK + scaffolding work. Build and UT OK on msvc15 x64. Not actually tested under *nix or emscripten yet
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
178 {
54cdad5a7228 Added a public function that will use emscripten-specific logging functions when using its SDK + scaffolding work. Build and UT OK on msvc15 x64. Not actually tested under *nix or emscripten yet
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
179 const char* text = "Trougoudou 53535345345353";
54cdad5a7228 Added a public function that will use emscripten-specific logging functions when using its SDK + scaffolding work. Build and UT OK on msvc15 x64. Not actually tested under *nix or emscripten yet
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
180 LOG(WARNING) << text;
54cdad5a7228 Added a public function that will use emscripten-specific logging functions when using its SDK + scaffolding work. Build and UT OK on msvc15 x64. Not actually tested under *nix or emscripten yet
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
181 std::string logLine = testWarningStream.str();
54cdad5a7228 Added a public function that will use emscripten-specific logging functions when using its SDK + scaffolding work. Build and UT OK on msvc15 x64. Not actually tested under *nix or emscripten yet
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
182 testWarningStream.str("");
54cdad5a7228 Added a public function that will use emscripten-specific logging functions when using its SDK + scaffolding work. Build and UT OK on msvc15 x64. Not actually tested under *nix or emscripten yet
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
183 testWarningStream.clear();
54cdad5a7228 Added a public function that will use emscripten-specific logging functions when using its SDK + scaffolding work. Build and UT OK on msvc15 x64. Not actually tested under *nix or emscripten yet
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
184 std::string payload;
54cdad5a7228 Added a public function that will use emscripten-specific logging functions when using its SDK + scaffolding work. Build and UT OK on msvc15 x64. Not actually tested under *nix or emscripten yet
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
185 bool ok = GetLogLinePayload(payload, logLine);
3359
815b81142ff7 Enable custom logging functions to redirect to emscripten specific logging calls
Benjamin Golinvaux <bgo@osimis.io>
parents: 3353
diff changeset
186 ASSERT_TRUE(ok);
3353
54cdad5a7228 Added a public function that will use emscripten-specific logging functions when using its SDK + scaffolding work. Build and UT OK on msvc15 x64. Not actually tested under *nix or emscripten yet
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
187 ASSERT_STREQ(payload.c_str(), text);
54cdad5a7228 Added a public function that will use emscripten-specific logging functions when using its SDK + scaffolding work. Build and UT OK on msvc15 x64. Not actually tested under *nix or emscripten yet
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
188 }
54cdad5a7228 Added a public function that will use emscripten-specific logging functions when using its SDK + scaffolding work. Build and UT OK on msvc15 x64. Not actually tested under *nix or emscripten yet
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
189
54cdad5a7228 Added a public function that will use emscripten-specific logging functions when using its SDK + scaffolding work. Build and UT OK on msvc15 x64. Not actually tested under *nix or emscripten yet
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
190 {
54cdad5a7228 Added a public function that will use emscripten-specific logging functions when using its SDK + scaffolding work. Build and UT OK on msvc15 x64. Not actually tested under *nix or emscripten yet
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
191 const char* text = "Prout 111929";
54cdad5a7228 Added a public function that will use emscripten-specific logging functions when using its SDK + scaffolding work. Build and UT OK on msvc15 x64. Not actually tested under *nix or emscripten yet
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
192 LOG(INFO) << text;
54cdad5a7228 Added a public function that will use emscripten-specific logging functions when using its SDK + scaffolding work. Build and UT OK on msvc15 x64. Not actually tested under *nix or emscripten yet
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
193 std::string logLine = testInfoStream.str();
54cdad5a7228 Added a public function that will use emscripten-specific logging functions when using its SDK + scaffolding work. Build and UT OK on msvc15 x64. Not actually tested under *nix or emscripten yet
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
194 testInfoStream.str("");
54cdad5a7228 Added a public function that will use emscripten-specific logging functions when using its SDK + scaffolding work. Build and UT OK on msvc15 x64. Not actually tested under *nix or emscripten yet
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
195 testInfoStream.clear();
54cdad5a7228 Added a public function that will use emscripten-specific logging functions when using its SDK + scaffolding work. Build and UT OK on msvc15 x64. Not actually tested under *nix or emscripten yet
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
196 std::string payload;
54cdad5a7228 Added a public function that will use emscripten-specific logging functions when using its SDK + scaffolding work. Build and UT OK on msvc15 x64. Not actually tested under *nix or emscripten yet
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
197 bool ok = GetLogLinePayload(payload, logLine);
3359
815b81142ff7 Enable custom logging functions to redirect to emscripten specific logging calls
Benjamin Golinvaux <bgo@osimis.io>
parents: 3353
diff changeset
198 ASSERT_TRUE(ok);
3353
54cdad5a7228 Added a public function that will use emscripten-specific logging functions when using its SDK + scaffolding work. Build and UT OK on msvc15 x64. Not actually tested under *nix or emscripten yet
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
199 ASSERT_STREQ(payload.c_str(), text);
54cdad5a7228 Added a public function that will use emscripten-specific logging functions when using its SDK + scaffolding work. Build and UT OK on msvc15 x64. Not actually tested under *nix or emscripten yet
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
200 }
4270
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
201
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
202 Orthanc::Logging::EnableTraceLevel(false); // Back to normal
3353
54cdad5a7228 Added a public function that will use emscripten-specific logging functions when using its SDK + scaffolding work. Build and UT OK on msvc15 x64. Not actually tested under *nix or emscripten yet
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
203 }
4325
b96aedfa8cc1 unit tests now running in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4299
diff changeset
204 #endif
4270
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
205
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
206
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
207
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
208 TEST(Logging, Categories)
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
209 {
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
210 using namespace Orthanc::Logging;
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
211
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
212 // Unit tests are running in "--verbose" mode (not "--trace")
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
213 ASSERT_FALSE(IsTraceLevelEnabled());
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
214 ASSERT_TRUE(IsInfoLevelEnabled());
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
215 ASSERT_TRUE(IsCategoryEnabled(LogLevel_INFO, LogCategory_SQLITE));
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
216 ASSERT_FALSE(IsCategoryEnabled(LogLevel_TRACE, LogCategory_SQLITE));
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
217
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
218 // Cannot modify categories for ERROR and WARNING
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
219 ASSERT_THROW(SetCategoryEnabled(LogLevel_ERROR, LogCategory_GENERIC, true),
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
220 Orthanc::OrthancException);
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
221 ASSERT_THROW(SetCategoryEnabled(LogLevel_WARNING, LogCategory_GENERIC, false),
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
222 Orthanc::OrthancException);
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
223
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
224
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
225 EnableInfoLevel(false);
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
226 EnableTraceLevel(false);
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
227 ASSERT_FALSE(IsTraceLevelEnabled());
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
228 ASSERT_FALSE(IsInfoLevelEnabled());
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
229 ASSERT_TRUE(IsCategoryEnabled(LogLevel_ERROR, LogCategory_GENERIC));
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
230 ASSERT_TRUE(IsCategoryEnabled(LogLevel_ERROR, LogCategory_DICOM));
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
231 ASSERT_TRUE(IsCategoryEnabled(LogLevel_ERROR, LogCategory_SQLITE));
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
232 ASSERT_TRUE(IsCategoryEnabled(LogLevel_WARNING, LogCategory_GENERIC));
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
233 ASSERT_TRUE(IsCategoryEnabled(LogLevel_WARNING, LogCategory_DICOM));
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
234 ASSERT_TRUE(IsCategoryEnabled(LogLevel_WARNING, LogCategory_SQLITE));
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
235 ASSERT_FALSE(IsCategoryEnabled(LogLevel_INFO, LogCategory_GENERIC));
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
236 ASSERT_FALSE(IsCategoryEnabled(LogLevel_INFO, LogCategory_DICOM));
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
237 ASSERT_FALSE(IsCategoryEnabled(LogLevel_INFO, LogCategory_SQLITE));
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
238 ASSERT_FALSE(IsCategoryEnabled(LogLevel_TRACE, LogCategory_GENERIC));
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
239 ASSERT_FALSE(IsCategoryEnabled(LogLevel_TRACE, LogCategory_DICOM));
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
240 ASSERT_FALSE(IsCategoryEnabled(LogLevel_TRACE, LogCategory_SQLITE));
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
241
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
242
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
243 // Test the "category" setters at INFO level
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
244 SetCategoryEnabled(LogLevel_INFO, LogCategory_DICOM, true);
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
245 ASSERT_FALSE(IsCategoryEnabled(LogLevel_INFO, LogCategory_GENERIC));
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
246 ASSERT_TRUE(IsCategoryEnabled(LogLevel_INFO, LogCategory_DICOM));
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
247 ASSERT_FALSE(IsCategoryEnabled(LogLevel_TRACE, LogCategory_GENERIC));
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
248 ASSERT_FALSE(IsCategoryEnabled(LogLevel_TRACE, LogCategory_DICOM));
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
249 ASSERT_FALSE(IsTraceLevelEnabled());
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
250 ASSERT_TRUE(IsInfoLevelEnabled()); // At least one category is verbose
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
251
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
252 SetCategoryEnabled(LogLevel_INFO, LogCategory_GENERIC, true);
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
253 ASSERT_TRUE(IsCategoryEnabled(LogLevel_INFO, LogCategory_GENERIC));
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
254 ASSERT_TRUE(IsCategoryEnabled(LogLevel_INFO, LogCategory_DICOM));
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
255 ASSERT_FALSE(IsCategoryEnabled(LogLevel_TRACE, LogCategory_GENERIC));
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
256 ASSERT_FALSE(IsCategoryEnabled(LogLevel_TRACE, LogCategory_DICOM));
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
257 ASSERT_FALSE(IsTraceLevelEnabled());
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
258 ASSERT_TRUE(IsInfoLevelEnabled());
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
259
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
260 SetCategoryEnabled(LogLevel_INFO, LogCategory_DICOM, false);
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
261 ASSERT_TRUE(IsCategoryEnabled(LogLevel_INFO, LogCategory_GENERIC));
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
262 ASSERT_FALSE(IsCategoryEnabled(LogLevel_INFO, LogCategory_DICOM));
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
263 ASSERT_FALSE(IsCategoryEnabled(LogLevel_TRACE, LogCategory_GENERIC));
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
264 ASSERT_FALSE(IsCategoryEnabled(LogLevel_TRACE, LogCategory_DICOM));
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
265 ASSERT_FALSE(IsTraceLevelEnabled());
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
266 ASSERT_TRUE(IsInfoLevelEnabled()); // "GENERIC" is still verbose
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
267
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
268 SetCategoryEnabled(LogLevel_INFO, LogCategory_GENERIC, false);
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
269 ASSERT_FALSE(IsCategoryEnabled(LogLevel_INFO, LogCategory_GENERIC));
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
270 ASSERT_FALSE(IsCategoryEnabled(LogLevel_INFO, LogCategory_DICOM));
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
271 ASSERT_FALSE(IsCategoryEnabled(LogLevel_TRACE, LogCategory_GENERIC));
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
272 ASSERT_FALSE(IsCategoryEnabled(LogLevel_TRACE, LogCategory_DICOM));
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
273 ASSERT_FALSE(IsTraceLevelEnabled());
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
274 ASSERT_FALSE(IsInfoLevelEnabled());
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
275
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
276
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
277 // Test the "category" setters at TRACE level
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
278 SetCategoryEnabled(LogLevel_TRACE, LogCategory_DICOM, true);
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
279 ASSERT_FALSE(IsCategoryEnabled(LogLevel_INFO, LogCategory_GENERIC));
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
280 ASSERT_TRUE(IsCategoryEnabled(LogLevel_INFO, LogCategory_DICOM));
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
281 ASSERT_FALSE(IsCategoryEnabled(LogLevel_TRACE, LogCategory_GENERIC));
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
282 ASSERT_TRUE(IsCategoryEnabled(LogLevel_TRACE, LogCategory_DICOM));
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
283 ASSERT_TRUE(IsTraceLevelEnabled());
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
284 ASSERT_TRUE(IsInfoLevelEnabled());
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
285
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
286 SetCategoryEnabled(LogLevel_TRACE, LogCategory_GENERIC, true);
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
287 ASSERT_TRUE(IsCategoryEnabled(LogLevel_INFO, LogCategory_GENERIC));
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
288 ASSERT_TRUE(IsCategoryEnabled(LogLevel_INFO, LogCategory_DICOM));
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
289 ASSERT_TRUE(IsCategoryEnabled(LogLevel_TRACE, LogCategory_GENERIC));
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
290 ASSERT_TRUE(IsCategoryEnabled(LogLevel_TRACE, LogCategory_DICOM));
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
291 ASSERT_TRUE(IsTraceLevelEnabled());
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
292 ASSERT_TRUE(IsInfoLevelEnabled());
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
293
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
294 SetCategoryEnabled(LogLevel_INFO, LogCategory_DICOM, false);
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
295 ASSERT_TRUE(IsCategoryEnabled(LogLevel_INFO, LogCategory_GENERIC));
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
296 ASSERT_FALSE(IsCategoryEnabled(LogLevel_INFO, LogCategory_DICOM));
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
297 ASSERT_TRUE(IsCategoryEnabled(LogLevel_TRACE, LogCategory_GENERIC));
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
298 ASSERT_FALSE(IsCategoryEnabled(LogLevel_TRACE, LogCategory_DICOM));
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
299 ASSERT_TRUE(IsTraceLevelEnabled()); // "GENERIC" is still at trace level
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
300 ASSERT_TRUE(IsInfoLevelEnabled());
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
301
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
302 SetCategoryEnabled(LogLevel_TRACE, LogCategory_GENERIC, false);
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
303 ASSERT_TRUE(IsCategoryEnabled(LogLevel_INFO, LogCategory_GENERIC));
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
304 ASSERT_FALSE(IsCategoryEnabled(LogLevel_INFO, LogCategory_DICOM));
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
305 ASSERT_FALSE(IsCategoryEnabled(LogLevel_TRACE, LogCategory_GENERIC));
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
306 ASSERT_FALSE(IsCategoryEnabled(LogLevel_TRACE, LogCategory_DICOM));
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
307 ASSERT_FALSE(IsTraceLevelEnabled());
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
308 ASSERT_TRUE(IsInfoLevelEnabled());
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
309
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
310 SetCategoryEnabled(LogLevel_INFO, LogCategory_GENERIC, false);
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
311 ASSERT_FALSE(IsCategoryEnabled(LogLevel_INFO, LogCategory_GENERIC));
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
312 ASSERT_FALSE(IsCategoryEnabled(LogLevel_INFO, LogCategory_DICOM));
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
313 ASSERT_FALSE(IsCategoryEnabled(LogLevel_TRACE, LogCategory_GENERIC));
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
314 ASSERT_FALSE(IsCategoryEnabled(LogLevel_TRACE, LogCategory_DICOM));
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
315 ASSERT_FALSE(IsTraceLevelEnabled());
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
316 ASSERT_FALSE(IsInfoLevelEnabled());
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
317
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
318
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
319
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
320 // Test the "macro" setters
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
321 EnableInfoLevel(true);
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
322 EnableTraceLevel(false);
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
323 ASSERT_FALSE(IsTraceLevelEnabled());
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
324 ASSERT_TRUE(IsInfoLevelEnabled());
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
325 ASSERT_TRUE(IsCategoryEnabled(LogLevel_ERROR, LogCategory_GENERIC));
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
326 ASSERT_TRUE(IsCategoryEnabled(LogLevel_ERROR, LogCategory_DICOM));
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
327 ASSERT_TRUE(IsCategoryEnabled(LogLevel_ERROR, LogCategory_SQLITE));
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
328 ASSERT_TRUE(IsCategoryEnabled(LogLevel_WARNING, LogCategory_GENERIC));
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
329 ASSERT_TRUE(IsCategoryEnabled(LogLevel_WARNING, LogCategory_DICOM));
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
330 ASSERT_TRUE(IsCategoryEnabled(LogLevel_WARNING, LogCategory_SQLITE));
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
331 ASSERT_TRUE(IsCategoryEnabled(LogLevel_INFO, LogCategory_GENERIC));
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
332 ASSERT_TRUE(IsCategoryEnabled(LogLevel_INFO, LogCategory_DICOM));
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
333 ASSERT_TRUE(IsCategoryEnabled(LogLevel_INFO, LogCategory_SQLITE));
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
334 ASSERT_FALSE(IsCategoryEnabled(LogLevel_TRACE, LogCategory_GENERIC));
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
335 ASSERT_FALSE(IsCategoryEnabled(LogLevel_TRACE, LogCategory_DICOM));
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
336 ASSERT_FALSE(IsCategoryEnabled(LogLevel_TRACE, LogCategory_SQLITE));
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
337
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
338 EnableInfoLevel(false);
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
339 EnableTraceLevel(true); // "--trace" implies "--verbose"
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
340 ASSERT_TRUE(IsTraceLevelEnabled());
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
341 ASSERT_TRUE(IsInfoLevelEnabled());
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
342 ASSERT_TRUE(IsCategoryEnabled(LogLevel_ERROR, LogCategory_GENERIC));
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
343 ASSERT_TRUE(IsCategoryEnabled(LogLevel_ERROR, LogCategory_DICOM));
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
344 ASSERT_TRUE(IsCategoryEnabled(LogLevel_ERROR, LogCategory_SQLITE));
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
345 ASSERT_TRUE(IsCategoryEnabled(LogLevel_WARNING, LogCategory_GENERIC));
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
346 ASSERT_TRUE(IsCategoryEnabled(LogLevel_WARNING, LogCategory_DICOM));
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
347 ASSERT_TRUE(IsCategoryEnabled(LogLevel_WARNING, LogCategory_SQLITE));
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
348 ASSERT_TRUE(IsCategoryEnabled(LogLevel_INFO, LogCategory_GENERIC));
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
349 ASSERT_TRUE(IsCategoryEnabled(LogLevel_INFO, LogCategory_DICOM));
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
350 ASSERT_TRUE(IsCategoryEnabled(LogLevel_INFO, LogCategory_SQLITE));
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
351 ASSERT_TRUE(IsCategoryEnabled(LogLevel_TRACE, LogCategory_GENERIC));
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
352 ASSERT_TRUE(IsCategoryEnabled(LogLevel_TRACE, LogCategory_DICOM));
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
353 ASSERT_TRUE(IsCategoryEnabled(LogLevel_TRACE, LogCategory_SQLITE));
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
354
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
355
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
356
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
357 // Back to normal
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
358 EnableInfoLevel(true);
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
359 EnableTraceLevel(false);
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
360 ASSERT_FALSE(IsTraceLevelEnabled());
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
361 ASSERT_TRUE(IsInfoLevelEnabled());
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
362 ASSERT_TRUE(IsCategoryEnabled(LogLevel_INFO, LogCategory_SQLITE));
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
363 ASSERT_FALSE(IsCategoryEnabled(LogLevel_TRACE, LogCategory_SQLITE));
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
364 }
4275
d7a50b7b8466 Dynamically access and/or change the verbosity of logging categories with the REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4270
diff changeset
365
d7a50b7b8466 Dynamically access and/or change the verbosity of logging categories with the REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4270
diff changeset
366
d7a50b7b8466 Dynamically access and/or change the verbosity of logging categories with the REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4270
diff changeset
367 TEST(Logging, Enumerations)
d7a50b7b8466 Dynamically access and/or change the verbosity of logging categories with the REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4270
diff changeset
368 {
d7a50b7b8466 Dynamically access and/or change the verbosity of logging categories with the REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4270
diff changeset
369 using namespace Orthanc;
d7a50b7b8466 Dynamically access and/or change the verbosity of logging categories with the REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4270
diff changeset
370
d7a50b7b8466 Dynamically access and/or change the verbosity of logging categories with the REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4270
diff changeset
371 Logging::LogCategory c;
d7a50b7b8466 Dynamically access and/or change the verbosity of logging categories with the REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4270
diff changeset
372 ASSERT_TRUE(Logging::LookupCategory(c, "generic")); ASSERT_EQ(Logging::LogCategory_GENERIC, c);
d7a50b7b8466 Dynamically access and/or change the verbosity of logging categories with the REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4270
diff changeset
373 ASSERT_TRUE(Logging::LookupCategory(c, "plugins")); ASSERT_EQ(Logging::LogCategory_PLUGINS, c);
4294
0923247e69f6 log categories: rest -> http + added lua & jobs
Alain Mazy <alain@mazy.be>
parents: 4276
diff changeset
374 ASSERT_TRUE(Logging::LookupCategory(c, "http")); ASSERT_EQ(Logging::LogCategory_HTTP, c);
4275
d7a50b7b8466 Dynamically access and/or change the verbosity of logging categories with the REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4270
diff changeset
375 ASSERT_TRUE(Logging::LookupCategory(c, "sqlite")); ASSERT_EQ(Logging::LogCategory_SQLITE, c);
d7a50b7b8466 Dynamically access and/or change the verbosity of logging categories with the REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4270
diff changeset
376 ASSERT_TRUE(Logging::LookupCategory(c, "dicom")); ASSERT_EQ(Logging::LogCategory_DICOM, c);
4294
0923247e69f6 log categories: rest -> http + added lua & jobs
Alain Mazy <alain@mazy.be>
parents: 4276
diff changeset
377 ASSERT_TRUE(Logging::LookupCategory(c, "jobs")); ASSERT_EQ(Logging::LogCategory_JOBS, c);
0923247e69f6 log categories: rest -> http + added lua & jobs
Alain Mazy <alain@mazy.be>
parents: 4276
diff changeset
378 ASSERT_TRUE(Logging::LookupCategory(c, "lua")); ASSERT_EQ(Logging::LogCategory_LUA, c);
4275
d7a50b7b8466 Dynamically access and/or change the verbosity of logging categories with the REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4270
diff changeset
379 ASSERT_FALSE(Logging::LookupCategory(c, "nope"));
d7a50b7b8466 Dynamically access and/or change the verbosity of logging categories with the REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4270
diff changeset
380
4294
0923247e69f6 log categories: rest -> http + added lua & jobs
Alain Mazy <alain@mazy.be>
parents: 4276
diff changeset
381 ASSERT_EQ(7u, Logging::GetCategoriesCount());
4275
d7a50b7b8466 Dynamically access and/or change the verbosity of logging categories with the REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4270
diff changeset
382
d7a50b7b8466 Dynamically access and/or change the verbosity of logging categories with the REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4270
diff changeset
383 std::set<std::string> s;
d7a50b7b8466 Dynamically access and/or change the verbosity of logging categories with the REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4270
diff changeset
384 for (size_t i = 0; i < Logging::GetCategoriesCount(); i++)
d7a50b7b8466 Dynamically access and/or change the verbosity of logging categories with the REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4270
diff changeset
385 {
d7a50b7b8466 Dynamically access and/or change the verbosity of logging categories with the REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4270
diff changeset
386 ASSERT_TRUE(Logging::LookupCategory(c, Logging::GetCategoryName(i)));
d7a50b7b8466 Dynamically access and/or change the verbosity of logging categories with the REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4270
diff changeset
387 s.insert(Logging::GetCategoryName(i));
d7a50b7b8466 Dynamically access and/or change the verbosity of logging categories with the REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4270
diff changeset
388 }
d7a50b7b8466 Dynamically access and/or change the verbosity of logging categories with the REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4270
diff changeset
389
4294
0923247e69f6 log categories: rest -> http + added lua & jobs
Alain Mazy <alain@mazy.be>
parents: 4276
diff changeset
390 ASSERT_EQ(7u, s.size());
4276
68e24935f258 fix for visual studio
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4275
diff changeset
391 ASSERT_TRUE(s.find("generic") != s.end());
68e24935f258 fix for visual studio
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4275
diff changeset
392 ASSERT_TRUE(s.find("plugins") != s.end());
4294
0923247e69f6 log categories: rest -> http + added lua & jobs
Alain Mazy <alain@mazy.be>
parents: 4276
diff changeset
393 ASSERT_TRUE(s.find("http") != s.end());
4276
68e24935f258 fix for visual studio
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4275
diff changeset
394 ASSERT_TRUE(s.find("sqlite") != s.end());
68e24935f258 fix for visual studio
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4275
diff changeset
395 ASSERT_TRUE(s.find("dicom") != s.end());
4294
0923247e69f6 log categories: rest -> http + added lua & jobs
Alain Mazy <alain@mazy.be>
parents: 4276
diff changeset
396 ASSERT_TRUE(s.find("lua") != s.end());
0923247e69f6 log categories: rest -> http + added lua & jobs
Alain Mazy <alain@mazy.be>
parents: 4276
diff changeset
397 ASSERT_TRUE(s.find("jobs") != s.end());
4275
d7a50b7b8466 Dynamically access and/or change the verbosity of logging categories with the REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4270
diff changeset
398
d7a50b7b8466 Dynamically access and/or change the verbosity of logging categories with the REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4270
diff changeset
399 ASSERT_THROW(Logging::GetCategoryName(Logging::GetCategoriesCount()), OrthancException);
d7a50b7b8466 Dynamically access and/or change the verbosity of logging categories with the REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4270
diff changeset
400
d7a50b7b8466 Dynamically access and/or change the verbosity of logging categories with the REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4270
diff changeset
401 ASSERT_STREQ("generic", Logging::GetCategoryName(Logging::LogCategory_GENERIC));
d7a50b7b8466 Dynamically access and/or change the verbosity of logging categories with the REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4270
diff changeset
402 ASSERT_STREQ("plugins", Logging::GetCategoryName(Logging::LogCategory_PLUGINS));
4294
0923247e69f6 log categories: rest -> http + added lua & jobs
Alain Mazy <alain@mazy.be>
parents: 4276
diff changeset
403 ASSERT_STREQ("http", Logging::GetCategoryName(Logging::LogCategory_HTTP));
4275
d7a50b7b8466 Dynamically access and/or change the verbosity of logging categories with the REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4270
diff changeset
404 ASSERT_STREQ("sqlite", Logging::GetCategoryName(Logging::LogCategory_SQLITE));
d7a50b7b8466 Dynamically access and/or change the verbosity of logging categories with the REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4270
diff changeset
405 ASSERT_STREQ("dicom", Logging::GetCategoryName(Logging::LogCategory_DICOM));
4294
0923247e69f6 log categories: rest -> http + added lua & jobs
Alain Mazy <alain@mazy.be>
parents: 4276
diff changeset
406 ASSERT_STREQ("lua", Logging::GetCategoryName(Logging::LogCategory_LUA));
0923247e69f6 log categories: rest -> http + added lua & jobs
Alain Mazy <alain@mazy.be>
parents: 4276
diff changeset
407 ASSERT_STREQ("jobs", Logging::GetCategoryName(Logging::LogCategory_JOBS));
4275
d7a50b7b8466 Dynamically access and/or change the verbosity of logging categories with the REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4270
diff changeset
408 }