annotate OrthancFramework/UnitTestsSources/LoggingTests.cpp @ 5798:ebd828518719 find-refactoring

merged default -> find-refactoring
author Alain Mazy <am@orthanc.team>
date Fri, 20 Sep 2024 08:20:55 +0200
parents f7adfb22e20e
children
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
5640
f7adfb22e20e updated copyright, as Orthanc Team now replaces Osimis
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5485
diff changeset
5 * Copyright (C) 2017-2023 Osimis S.A., Belgium
f7adfb22e20e updated copyright, as Orthanc Team now replaces Osimis
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5485
diff changeset
6 * Copyright (C) 2024-2024 Orthanc Team SRL, Belgium
5485
48b8dae6dc77 upgrade to year 2024
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5458
diff changeset
7 * Copyright (C) 2021-2024 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
8 *
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
9 * 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
10 * 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
11 * 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
12 * 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
13 *
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 * 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
15 * 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
16 * 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
17 * 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
18 *
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
19 * 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
20 * 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
21 * <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
22 **/
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
23
3992
f9863630ec7f working on the shared library for Orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
24
f9863630ec7f working on the shared library for Orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
25 #if ORTHANC_UNIT_TESTS_LINK_FRAMEWORK == 1
4063
e00f3d089991 shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4062
diff changeset
26 // 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
27 # include <OrthancFramework.h>
3992
f9863630ec7f working on the shared library for Orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
28 #endif
f9863630ec7f working on the shared library for Orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
29
4062
0953b3dc3261 pretty-printing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4045
diff changeset
30 #include <gtest/gtest.h>
0953b3dc3261 pretty-printing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4045
diff changeset
31
0953b3dc3261 pretty-printing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4045
diff changeset
32 #include "../Sources/Logging.h"
4270
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
33 #include "../Sources/OrthancException.h"
4062
0953b3dc3261 pretty-printing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4045
diff changeset
34
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
35 #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
36 #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
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
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 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
40 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
41 {
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 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
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
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 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
46 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
47 {
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 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
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
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 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
52 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
53 {
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 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
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
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
57 /**
4008
2d4427ca4be9 removed Core/LoggingUtils.h
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4004
diff changeset
58 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
59
4008
2d4427ca4be9 removed Core/LoggingUtils.h
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4004
diff changeset
60 "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
61 -->
2d4427ca4be9 removed Core/LoggingUtils.h
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4004
diff changeset
62 "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
63
4008
2d4427ca4be9 removed Core/LoggingUtils.h
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4004
diff changeset
64 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
65 */
3359
815b81142ff7 Enable custom logging functions to redirect to emscripten specific logging calls
Benjamin Golinvaux <bgo@osimis.io>
parents: 3353
diff changeset
66
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
67 #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
68
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
69 static bool GetLogLinePayload(std::string& payload,
4008
2d4427ca4be9 removed Core/LoggingUtils.h
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4004
diff changeset
70 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
71 {
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
72 const char* regexStr = "[A-Z][0-9]{4} [0-9]{2}:[0-9]{2}:[0-9]{2}.[0-9]{6} "
5458
d7c9c85d78dc fix logging unit tests
Alain Mazy <am@osimis.io>
parents: 5185
diff changeset
73 ".{16} [a-zA-Z\\.\\-_]+:[0-9]+\\] (.*)" EOLSTRING "$";
3359
815b81142ff7 Enable custom logging functions to redirect to emscripten specific logging calls
Benjamin Golinvaux <bgo@osimis.io>
parents: 3353
diff changeset
74
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
75 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
76
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 //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
78 //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
79 // "[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
80 //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
81 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
82 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
83 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
84 {
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 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
86 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
87 }
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 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
89 {
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 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
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 }
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
93
4008
2d4427ca4be9 removed Core/LoggingUtils.h
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4004
diff changeset
94
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
95 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
96 {
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 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
98 {
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
99 public:
4003
3c19371090c3 removing useless LoggingMemento
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3992
diff changeset
100 LoggingMementoScope()
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 }
3c19371090c3 removing useless LoggingMemento
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3992
diff changeset
103
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
104 ~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
105 {
4003
3c19371090c3 removing useless LoggingMemento
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3992
diff changeset
106 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
107 }
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
108 };
4008
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 /**
2d4427ca4be9 removed Core/LoggingUtils.h
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4004
diff changeset
112 * std::streambuf subclass used in FunctionCallingStream
2d4427ca4be9 removed Core/LoggingUtils.h
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4004
diff changeset
113 **/
2d4427ca4be9 removed Core/LoggingUtils.h
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4004
diff changeset
114 template<typename T>
2d4427ca4be9 removed Core/LoggingUtils.h
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4004
diff changeset
115 class FuncStreamBuf : public std::stringbuf
2d4427ca4be9 removed Core/LoggingUtils.h
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4004
diff changeset
116 {
2d4427ca4be9 removed Core/LoggingUtils.h
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4004
diff changeset
117 public:
4204
318c16cfccab cppcheck
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4119
diff changeset
118 explicit FuncStreamBuf(T func) : func_(func) {}
4008
2d4427ca4be9 removed Core/LoggingUtils.h
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4004
diff changeset
119
2d4427ca4be9 removed Core/LoggingUtils.h
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4004
diff changeset
120 virtual int sync()
2d4427ca4be9 removed Core/LoggingUtils.h
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4004
diff changeset
121 {
2d4427ca4be9 removed Core/LoggingUtils.h
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4004
diff changeset
122 std::string text = this->str();
2d4427ca4be9 removed Core/LoggingUtils.h
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4004
diff changeset
123 const char* buf = text.c_str();
2d4427ca4be9 removed Core/LoggingUtils.h
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4004
diff changeset
124 func_(buf);
2d4427ca4be9 removed Core/LoggingUtils.h
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4004
diff changeset
125 this->str("");
2d4427ca4be9 removed Core/LoggingUtils.h
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4004
diff changeset
126 return 0;
2d4427ca4be9 removed Core/LoggingUtils.h
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4004
diff changeset
127 }
2d4427ca4be9 removed Core/LoggingUtils.h
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4004
diff changeset
128 private:
2d4427ca4be9 removed Core/LoggingUtils.h
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4004
diff changeset
129 T func_;
2d4427ca4be9 removed Core/LoggingUtils.h
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4004
diff changeset
130 };
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
131 }
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
132
4008
2d4427ca4be9 removed Core/LoggingUtils.h
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4004
diff changeset
133
4325
b96aedfa8cc1 unit tests now running in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4299
diff changeset
134 #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
135 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
136 {
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 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
138
4270
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
139 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
140
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 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
142
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 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
144 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
145
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 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
147 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
148
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 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
150 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
151
4270
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
152 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
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 {
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 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
156 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
157 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
158 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
159 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
160 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
161 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
162 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
163 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
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
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 // 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
167 {
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 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
169 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
170 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
171 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
172 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
173 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
174 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
175 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
176 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
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 {
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 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
181 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
182 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
183 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
184 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
185 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
186 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
187 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
188 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
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 {
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 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
193 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
194 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
195 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
196 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
197 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
198 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
199 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
200 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
201 }
4270
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
202
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
203 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
204 }
4325
b96aedfa8cc1 unit tests now running in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4299
diff changeset
205 #endif
4270
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
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
209 TEST(Logging, Categories)
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
210 {
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
211 using namespace Orthanc::Logging;
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
212
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
213 // Unit tests are running in "--verbose" mode (not "--trace")
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
214 ASSERT_FALSE(IsTraceLevelEnabled());
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
215 ASSERT_TRUE(IsInfoLevelEnabled());
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
216 ASSERT_TRUE(IsCategoryEnabled(LogLevel_INFO, LogCategory_SQLITE));
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
217 ASSERT_FALSE(IsCategoryEnabled(LogLevel_TRACE, LogCategory_SQLITE));
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
218
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
219 // Cannot modify categories for ERROR and WARNING
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
220 ASSERT_THROW(SetCategoryEnabled(LogLevel_ERROR, LogCategory_GENERIC, true),
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
221 Orthanc::OrthancException);
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
222 ASSERT_THROW(SetCategoryEnabled(LogLevel_WARNING, LogCategory_GENERIC, false),
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
223 Orthanc::OrthancException);
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
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
226 EnableInfoLevel(false);
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
227 EnableTraceLevel(false);
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
228 ASSERT_FALSE(IsTraceLevelEnabled());
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
229 ASSERT_FALSE(IsInfoLevelEnabled());
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
230 ASSERT_TRUE(IsCategoryEnabled(LogLevel_ERROR, LogCategory_GENERIC));
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
231 ASSERT_TRUE(IsCategoryEnabled(LogLevel_ERROR, LogCategory_DICOM));
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
232 ASSERT_TRUE(IsCategoryEnabled(LogLevel_ERROR, LogCategory_SQLITE));
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
233 ASSERT_TRUE(IsCategoryEnabled(LogLevel_WARNING, LogCategory_GENERIC));
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
234 ASSERT_TRUE(IsCategoryEnabled(LogLevel_WARNING, LogCategory_DICOM));
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
235 ASSERT_TRUE(IsCategoryEnabled(LogLevel_WARNING, LogCategory_SQLITE));
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
236 ASSERT_FALSE(IsCategoryEnabled(LogLevel_INFO, LogCategory_GENERIC));
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
237 ASSERT_FALSE(IsCategoryEnabled(LogLevel_INFO, LogCategory_DICOM));
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
238 ASSERT_FALSE(IsCategoryEnabled(LogLevel_INFO, LogCategory_SQLITE));
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
239 ASSERT_FALSE(IsCategoryEnabled(LogLevel_TRACE, LogCategory_GENERIC));
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
240 ASSERT_FALSE(IsCategoryEnabled(LogLevel_TRACE, LogCategory_DICOM));
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
241 ASSERT_FALSE(IsCategoryEnabled(LogLevel_TRACE, LogCategory_SQLITE));
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
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
244 // Test the "category" setters at INFO level
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
245 SetCategoryEnabled(LogLevel_INFO, LogCategory_DICOM, true);
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
246 ASSERT_FALSE(IsCategoryEnabled(LogLevel_INFO, LogCategory_GENERIC));
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
247 ASSERT_TRUE(IsCategoryEnabled(LogLevel_INFO, LogCategory_DICOM));
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
248 ASSERT_FALSE(IsCategoryEnabled(LogLevel_TRACE, LogCategory_GENERIC));
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
249 ASSERT_FALSE(IsCategoryEnabled(LogLevel_TRACE, LogCategory_DICOM));
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
250 ASSERT_FALSE(IsTraceLevelEnabled());
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
251 ASSERT_TRUE(IsInfoLevelEnabled()); // At least one category is verbose
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
252
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
253 SetCategoryEnabled(LogLevel_INFO, LogCategory_GENERIC, true);
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
254 ASSERT_TRUE(IsCategoryEnabled(LogLevel_INFO, LogCategory_GENERIC));
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
255 ASSERT_TRUE(IsCategoryEnabled(LogLevel_INFO, LogCategory_DICOM));
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
256 ASSERT_FALSE(IsCategoryEnabled(LogLevel_TRACE, LogCategory_GENERIC));
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
257 ASSERT_FALSE(IsCategoryEnabled(LogLevel_TRACE, LogCategory_DICOM));
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
258 ASSERT_FALSE(IsTraceLevelEnabled());
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
259 ASSERT_TRUE(IsInfoLevelEnabled());
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
260
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
261 SetCategoryEnabled(LogLevel_INFO, LogCategory_DICOM, false);
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
262 ASSERT_TRUE(IsCategoryEnabled(LogLevel_INFO, LogCategory_GENERIC));
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
263 ASSERT_FALSE(IsCategoryEnabled(LogLevel_INFO, LogCategory_DICOM));
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
264 ASSERT_FALSE(IsCategoryEnabled(LogLevel_TRACE, LogCategory_GENERIC));
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
265 ASSERT_FALSE(IsCategoryEnabled(LogLevel_TRACE, LogCategory_DICOM));
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
266 ASSERT_FALSE(IsTraceLevelEnabled());
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
267 ASSERT_TRUE(IsInfoLevelEnabled()); // "GENERIC" is still verbose
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
268
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
269 SetCategoryEnabled(LogLevel_INFO, LogCategory_GENERIC, false);
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
270 ASSERT_FALSE(IsCategoryEnabled(LogLevel_INFO, LogCategory_GENERIC));
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
271 ASSERT_FALSE(IsCategoryEnabled(LogLevel_INFO, LogCategory_DICOM));
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
272 ASSERT_FALSE(IsCategoryEnabled(LogLevel_TRACE, LogCategory_GENERIC));
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
273 ASSERT_FALSE(IsCategoryEnabled(LogLevel_TRACE, LogCategory_DICOM));
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
274 ASSERT_FALSE(IsTraceLevelEnabled());
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
275 ASSERT_FALSE(IsInfoLevelEnabled());
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
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
278 // Test the "category" setters at TRACE level
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
279 SetCategoryEnabled(LogLevel_TRACE, LogCategory_DICOM, true);
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
280 ASSERT_FALSE(IsCategoryEnabled(LogLevel_INFO, LogCategory_GENERIC));
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
281 ASSERT_TRUE(IsCategoryEnabled(LogLevel_INFO, LogCategory_DICOM));
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
282 ASSERT_FALSE(IsCategoryEnabled(LogLevel_TRACE, LogCategory_GENERIC));
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
283 ASSERT_TRUE(IsCategoryEnabled(LogLevel_TRACE, LogCategory_DICOM));
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
284 ASSERT_TRUE(IsTraceLevelEnabled());
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
285 ASSERT_TRUE(IsInfoLevelEnabled());
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
286
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
287 SetCategoryEnabled(LogLevel_TRACE, LogCategory_GENERIC, true);
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
288 ASSERT_TRUE(IsCategoryEnabled(LogLevel_INFO, LogCategory_GENERIC));
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
289 ASSERT_TRUE(IsCategoryEnabled(LogLevel_INFO, LogCategory_DICOM));
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
290 ASSERT_TRUE(IsCategoryEnabled(LogLevel_TRACE, LogCategory_GENERIC));
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
291 ASSERT_TRUE(IsCategoryEnabled(LogLevel_TRACE, LogCategory_DICOM));
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
292 ASSERT_TRUE(IsTraceLevelEnabled());
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
293 ASSERT_TRUE(IsInfoLevelEnabled());
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
294
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
295 SetCategoryEnabled(LogLevel_INFO, LogCategory_DICOM, false);
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
296 ASSERT_TRUE(IsCategoryEnabled(LogLevel_INFO, LogCategory_GENERIC));
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
297 ASSERT_FALSE(IsCategoryEnabled(LogLevel_INFO, LogCategory_DICOM));
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
298 ASSERT_TRUE(IsCategoryEnabled(LogLevel_TRACE, LogCategory_GENERIC));
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
299 ASSERT_FALSE(IsCategoryEnabled(LogLevel_TRACE, LogCategory_DICOM));
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
300 ASSERT_TRUE(IsTraceLevelEnabled()); // "GENERIC" is still at trace level
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
301 ASSERT_TRUE(IsInfoLevelEnabled());
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
302
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
303 SetCategoryEnabled(LogLevel_TRACE, LogCategory_GENERIC, false);
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
304 ASSERT_TRUE(IsCategoryEnabled(LogLevel_INFO, LogCategory_GENERIC));
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
305 ASSERT_FALSE(IsCategoryEnabled(LogLevel_INFO, LogCategory_DICOM));
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
306 ASSERT_FALSE(IsCategoryEnabled(LogLevel_TRACE, LogCategory_GENERIC));
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
307 ASSERT_FALSE(IsCategoryEnabled(LogLevel_TRACE, LogCategory_DICOM));
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
308 ASSERT_FALSE(IsTraceLevelEnabled());
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
309 ASSERT_TRUE(IsInfoLevelEnabled());
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
310
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
311 SetCategoryEnabled(LogLevel_INFO, LogCategory_GENERIC, false);
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
312 ASSERT_FALSE(IsCategoryEnabled(LogLevel_INFO, LogCategory_GENERIC));
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
313 ASSERT_FALSE(IsCategoryEnabled(LogLevel_INFO, LogCategory_DICOM));
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
314 ASSERT_FALSE(IsCategoryEnabled(LogLevel_TRACE, LogCategory_GENERIC));
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
315 ASSERT_FALSE(IsCategoryEnabled(LogLevel_TRACE, LogCategory_DICOM));
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
316 ASSERT_FALSE(IsTraceLevelEnabled());
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
317 ASSERT_FALSE(IsInfoLevelEnabled());
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
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
321 // Test the "macro" setters
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
322 EnableInfoLevel(true);
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
323 EnableTraceLevel(false);
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
324 ASSERT_FALSE(IsTraceLevelEnabled());
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
325 ASSERT_TRUE(IsInfoLevelEnabled());
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
326 ASSERT_TRUE(IsCategoryEnabled(LogLevel_ERROR, LogCategory_GENERIC));
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
327 ASSERT_TRUE(IsCategoryEnabled(LogLevel_ERROR, LogCategory_DICOM));
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
328 ASSERT_TRUE(IsCategoryEnabled(LogLevel_ERROR, LogCategory_SQLITE));
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
329 ASSERT_TRUE(IsCategoryEnabled(LogLevel_WARNING, LogCategory_GENERIC));
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
330 ASSERT_TRUE(IsCategoryEnabled(LogLevel_WARNING, LogCategory_DICOM));
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
331 ASSERT_TRUE(IsCategoryEnabled(LogLevel_WARNING, LogCategory_SQLITE));
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
332 ASSERT_TRUE(IsCategoryEnabled(LogLevel_INFO, LogCategory_GENERIC));
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
333 ASSERT_TRUE(IsCategoryEnabled(LogLevel_INFO, LogCategory_DICOM));
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
334 ASSERT_TRUE(IsCategoryEnabled(LogLevel_INFO, LogCategory_SQLITE));
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
335 ASSERT_FALSE(IsCategoryEnabled(LogLevel_TRACE, LogCategory_GENERIC));
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
336 ASSERT_FALSE(IsCategoryEnabled(LogLevel_TRACE, LogCategory_DICOM));
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
337 ASSERT_FALSE(IsCategoryEnabled(LogLevel_TRACE, LogCategory_SQLITE));
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
338
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
339 EnableInfoLevel(false);
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
340 EnableTraceLevel(true); // "--trace" implies "--verbose"
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
341 ASSERT_TRUE(IsTraceLevelEnabled());
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
342 ASSERT_TRUE(IsInfoLevelEnabled());
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
343 ASSERT_TRUE(IsCategoryEnabled(LogLevel_ERROR, LogCategory_GENERIC));
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
344 ASSERT_TRUE(IsCategoryEnabled(LogLevel_ERROR, LogCategory_DICOM));
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
345 ASSERT_TRUE(IsCategoryEnabled(LogLevel_ERROR, LogCategory_SQLITE));
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
346 ASSERT_TRUE(IsCategoryEnabled(LogLevel_WARNING, LogCategory_GENERIC));
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
347 ASSERT_TRUE(IsCategoryEnabled(LogLevel_WARNING, LogCategory_DICOM));
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
348 ASSERT_TRUE(IsCategoryEnabled(LogLevel_WARNING, LogCategory_SQLITE));
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
349 ASSERT_TRUE(IsCategoryEnabled(LogLevel_INFO, LogCategory_GENERIC));
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
350 ASSERT_TRUE(IsCategoryEnabled(LogLevel_INFO, LogCategory_DICOM));
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
351 ASSERT_TRUE(IsCategoryEnabled(LogLevel_INFO, LogCategory_SQLITE));
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
352 ASSERT_TRUE(IsCategoryEnabled(LogLevel_TRACE, LogCategory_GENERIC));
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
353 ASSERT_TRUE(IsCategoryEnabled(LogLevel_TRACE, LogCategory_DICOM));
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
354 ASSERT_TRUE(IsCategoryEnabled(LogLevel_TRACE, LogCategory_SQLITE));
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
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
358 // Back to normal
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
359 EnableInfoLevel(true);
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
360 EnableTraceLevel(false);
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
361 ASSERT_FALSE(IsTraceLevelEnabled());
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
362 ASSERT_TRUE(IsInfoLevelEnabled());
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
363 ASSERT_TRUE(IsCategoryEnabled(LogLevel_INFO, LogCategory_SQLITE));
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
364 ASSERT_FALSE(IsCategoryEnabled(LogLevel_TRACE, LogCategory_SQLITE));
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
365 }
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
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
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 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
369 {
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 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
371
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 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
373 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
374 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
375 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
376 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
377 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
378 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
379 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
380 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
381
4294
0923247e69f6 log categories: rest -> http + added lua & jobs
Alain Mazy <alain@mazy.be>
parents: 4276
diff changeset
382 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
383
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 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
385 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
386 {
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 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
388 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
389 }
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
390
4294
0923247e69f6 log categories: rest -> http + added lua & jobs
Alain Mazy <alain@mazy.be>
parents: 4276
diff changeset
391 ASSERT_EQ(7u, s.size());
4276
68e24935f258 fix for visual studio
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4275
diff changeset
392 ASSERT_TRUE(s.find("generic") != s.end());
68e24935f258 fix for visual studio
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4275
diff changeset
393 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
394 ASSERT_TRUE(s.find("http") != s.end());
4276
68e24935f258 fix for visual studio
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4275
diff changeset
395 ASSERT_TRUE(s.find("sqlite") != s.end());
68e24935f258 fix for visual studio
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4275
diff changeset
396 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
397 ASSERT_TRUE(s.find("lua") != s.end());
0923247e69f6 log categories: rest -> http + added lua & jobs
Alain Mazy <alain@mazy.be>
parents: 4276
diff changeset
398 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
399
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 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
401
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("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
403 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
404 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
405 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
406 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
407 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
408 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
409 }