annotate OrthancFramework/UnitTestsSources/LoggingTests.cpp @ 4299:3f85db78c441

cppcheck
author Sebastien Jodogne <s.jodogne@gmail.com>
date Thu, 05 Nov 2020 18:24:50 +0100
parents 0923247e69f6
children b96aedfa8cc1
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
3640
94f4a18a79cc upgrade to year 2020
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3471
diff changeset
5 * Copyright (C) 2017-2020 Osimis S.A., 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
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
7 * 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
8 * 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
9 * 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
10 * 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
11 *
54cdad5a7228 Added a public function that will use emscripten-specific logging functions when using its SDK + scaffolding 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 * 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
13 * 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
14 * 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
15 * 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
16 *
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 * 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
18 * 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
19 * <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
20 **/
54cdad5a7228 Added a public function that will use emscripten-specific logging functions when using its SDK + scaffolding 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
3992
f9863630ec7f working on the shared library for Orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
22
f9863630ec7f working on the shared library for Orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
23 #if ORTHANC_UNIT_TESTS_LINK_FRAMEWORK == 1
4063
e00f3d089991 shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4062
diff changeset
24 // 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
25 # include <OrthancFramework.h>
3992
f9863630ec7f working on the shared library for Orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
26 #endif
f9863630ec7f working on the shared library for Orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
27
4062
0953b3dc3261 pretty-printing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4045
diff changeset
28 #include <gtest/gtest.h>
0953b3dc3261 pretty-printing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4045
diff changeset
29
0953b3dc3261 pretty-printing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4045
diff changeset
30 #include "../Sources/Logging.h"
4270
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
31 #include "../Sources/OrthancException.h"
4062
0953b3dc3261 pretty-printing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4045
diff changeset
32
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
33 #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
34 #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
35
54cdad5a7228 Added a public function that will use emscripten-specific logging functions when using its SDK + scaffolding 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 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
38 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
39 {
54cdad5a7228 Added a public function that will use emscripten-specific logging functions when using its SDK + scaffolding 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 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
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
54cdad5a7228 Added a public function that will use emscripten-specific logging functions when using its SDK + scaffolding 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 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
44 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
45 {
54cdad5a7228 Added a public function that will use emscripten-specific logging functions when using its SDK + scaffolding 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 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
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
54cdad5a7228 Added a public function that will use emscripten-specific logging functions when using its SDK + scaffolding 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 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
50 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
51 {
54cdad5a7228 Added a public function that will use emscripten-specific logging functions when using its SDK + scaffolding 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 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
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
54cdad5a7228 Added a public function that will use emscripten-specific logging functions when using its SDK + scaffolding 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 /**
4008
2d4427ca4be9 removed Core/LoggingUtils.h
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4004
diff changeset
56 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
57
4008
2d4427ca4be9 removed Core/LoggingUtils.h
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4004
diff changeset
58 "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
59 -->
2d4427ca4be9 removed Core/LoggingUtils.h
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4004
diff changeset
60 "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
61
4008
2d4427ca4be9 removed Core/LoggingUtils.h
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4004
diff changeset
62 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
63 */
3359
815b81142ff7 Enable custom logging functions to redirect to emscripten specific logging calls
Benjamin Golinvaux <bgo@osimis.io>
parents: 3353
diff changeset
64
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
65 #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
66
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
67 static bool GetLogLinePayload(std::string& payload,
4008
2d4427ca4be9 removed Core/LoggingUtils.h
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4004
diff changeset
68 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
69 {
54cdad5a7228 Added a public function that will use emscripten-specific logging functions when using its SDK + scaffolding 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 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
71 "[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
72
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
73 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
74
54cdad5a7228 Added a public function that will use emscripten-specific logging functions when using its SDK + scaffolding 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 //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
76 //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
77 // "[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
78 //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
79 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
80 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
81 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
82 {
54cdad5a7228 Added a public function that will use emscripten-specific logging functions when using its SDK + scaffolding 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 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
84 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
85 }
54cdad5a7228 Added a public function that will use emscripten-specific logging functions when using its SDK + scaffolding 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 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
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 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
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 }
54cdad5a7228 Added a public function that will use emscripten-specific logging functions when using its SDK + scaffolding 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
4008
2d4427ca4be9 removed Core/LoggingUtils.h
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4004
diff changeset
92
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
93 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
94 {
54cdad5a7228 Added a public function that will use emscripten-specific logging functions when using its SDK + scaffolding 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 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
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 public:
4003
3c19371090c3 removing useless LoggingMemento
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3992
diff changeset
98 LoggingMementoScope()
3c19371090c3 removing useless LoggingMemento
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3992
diff changeset
99 {
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
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
102 ~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
103 {
4003
3c19371090c3 removing useless LoggingMemento
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3992
diff changeset
104 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
105 }
54cdad5a7228 Added a public function that will use emscripten-specific logging functions when using its SDK + scaffolding 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 };
4008
2d4427ca4be9 removed Core/LoggingUtils.h
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4004
diff changeset
107
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 * std::streambuf subclass used in FunctionCallingStream
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 template<typename T>
2d4427ca4be9 removed Core/LoggingUtils.h
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4004
diff changeset
113 class FuncStreamBuf : public std::stringbuf
2d4427ca4be9 removed Core/LoggingUtils.h
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4004
diff changeset
114 {
2d4427ca4be9 removed Core/LoggingUtils.h
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4004
diff changeset
115 public:
4204
318c16cfccab cppcheck
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4119
diff changeset
116 explicit FuncStreamBuf(T func) : func_(func) {}
4008
2d4427ca4be9 removed Core/LoggingUtils.h
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4004
diff changeset
117
2d4427ca4be9 removed Core/LoggingUtils.h
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4004
diff changeset
118 virtual int sync()
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 std::string text = this->str();
2d4427ca4be9 removed Core/LoggingUtils.h
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4004
diff changeset
121 const char* buf = text.c_str();
2d4427ca4be9 removed Core/LoggingUtils.h
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4004
diff changeset
122 func_(buf);
2d4427ca4be9 removed Core/LoggingUtils.h
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4004
diff changeset
123 this->str("");
2d4427ca4be9 removed Core/LoggingUtils.h
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4004
diff changeset
124 return 0;
2d4427ca4be9 removed Core/LoggingUtils.h
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4004
diff changeset
125 }
2d4427ca4be9 removed Core/LoggingUtils.h
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4004
diff changeset
126 private:
2d4427ca4be9 removed Core/LoggingUtils.h
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4004
diff changeset
127 T func_;
2d4427ca4be9 removed Core/LoggingUtils.h
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4004
diff changeset
128 };
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
129 }
54cdad5a7228 Added a public function that will use emscripten-specific logging functions when using its SDK + scaffolding 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
4008
2d4427ca4be9 removed Core/LoggingUtils.h
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4004
diff changeset
131
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
132 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
133 {
54cdad5a7228 Added a public function that will use emscripten-specific logging functions when using its SDK + scaffolding 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 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
135
4270
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
136 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
137
54cdad5a7228 Added a public function that will use emscripten-specific logging functions when using its SDK + scaffolding 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 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
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 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
141 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
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> 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
144 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
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> 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
147 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
148
4270
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
149 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
150
54cdad5a7228 Added a public function that will use emscripten-specific logging functions when using its SDK + scaffolding 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 {
54cdad5a7228 Added a public function that will use emscripten-specific logging functions when using its SDK + scaffolding 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 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
153 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
154 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
155 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
156 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
157 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
158 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
159 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
160 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
161 }
54cdad5a7228 Added a public function that will use emscripten-specific logging functions when using its SDK + scaffolding 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
54cdad5a7228 Added a public function that will use emscripten-specific logging functions when using its SDK + scaffolding 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 // 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
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 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
166 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
167 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
168 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
169 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
170 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
171 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
172 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
173 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
174 }
54cdad5a7228 Added a public function that will use emscripten-specific logging functions when using its SDK + scaffolding 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
54cdad5a7228 Added a public function that will use emscripten-specific logging functions when using its SDK + scaffolding 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 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
178 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
179 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
180 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
181 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
182 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
183 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
184 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
185 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
186 }
54cdad5a7228 Added a public function that will use emscripten-specific logging functions when using its SDK + scaffolding 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
54cdad5a7228 Added a public function that will use emscripten-specific logging functions when using its SDK + scaffolding 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 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
190 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
191 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
192 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
193 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
194 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
195 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
196 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
197 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
198 }
4270
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
199
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
200 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
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
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
204
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
205 TEST(Logging, Categories)
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 using namespace Orthanc::Logging;
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 // Unit tests are running in "--verbose" mode (not "--trace")
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
210 ASSERT_FALSE(IsTraceLevelEnabled());
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
211 ASSERT_TRUE(IsInfoLevelEnabled());
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
212 ASSERT_TRUE(IsCategoryEnabled(LogLevel_INFO, LogCategory_SQLITE));
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
213 ASSERT_FALSE(IsCategoryEnabled(LogLevel_TRACE, LogCategory_SQLITE));
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
214
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
215 // Cannot modify categories for ERROR and WARNING
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
216 ASSERT_THROW(SetCategoryEnabled(LogLevel_ERROR, LogCategory_GENERIC, true),
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
217 Orthanc::OrthancException);
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
218 ASSERT_THROW(SetCategoryEnabled(LogLevel_WARNING, LogCategory_GENERIC, false),
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
219 Orthanc::OrthancException);
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
220
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
221
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
222 EnableInfoLevel(false);
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
223 EnableTraceLevel(false);
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
224 ASSERT_FALSE(IsTraceLevelEnabled());
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
225 ASSERT_FALSE(IsInfoLevelEnabled());
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
226 ASSERT_TRUE(IsCategoryEnabled(LogLevel_ERROR, LogCategory_GENERIC));
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
227 ASSERT_TRUE(IsCategoryEnabled(LogLevel_ERROR, LogCategory_DICOM));
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
228 ASSERT_TRUE(IsCategoryEnabled(LogLevel_ERROR, LogCategory_SQLITE));
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
229 ASSERT_TRUE(IsCategoryEnabled(LogLevel_WARNING, LogCategory_GENERIC));
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
230 ASSERT_TRUE(IsCategoryEnabled(LogLevel_WARNING, LogCategory_DICOM));
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
231 ASSERT_TRUE(IsCategoryEnabled(LogLevel_WARNING, LogCategory_SQLITE));
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
232 ASSERT_FALSE(IsCategoryEnabled(LogLevel_INFO, LogCategory_GENERIC));
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
233 ASSERT_FALSE(IsCategoryEnabled(LogLevel_INFO, LogCategory_DICOM));
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
234 ASSERT_FALSE(IsCategoryEnabled(LogLevel_INFO, LogCategory_SQLITE));
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
235 ASSERT_FALSE(IsCategoryEnabled(LogLevel_TRACE, LogCategory_GENERIC));
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
236 ASSERT_FALSE(IsCategoryEnabled(LogLevel_TRACE, LogCategory_DICOM));
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
237 ASSERT_FALSE(IsCategoryEnabled(LogLevel_TRACE, LogCategory_SQLITE));
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
238
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
239
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
240 // Test the "category" setters at INFO level
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
241 SetCategoryEnabled(LogLevel_INFO, LogCategory_DICOM, true);
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
242 ASSERT_FALSE(IsCategoryEnabled(LogLevel_INFO, LogCategory_GENERIC));
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
243 ASSERT_TRUE(IsCategoryEnabled(LogLevel_INFO, LogCategory_DICOM));
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
244 ASSERT_FALSE(IsCategoryEnabled(LogLevel_TRACE, LogCategory_GENERIC));
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
245 ASSERT_FALSE(IsCategoryEnabled(LogLevel_TRACE, LogCategory_DICOM));
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
246 ASSERT_FALSE(IsTraceLevelEnabled());
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
247 ASSERT_TRUE(IsInfoLevelEnabled()); // At least one category is verbose
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
248
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
249 SetCategoryEnabled(LogLevel_INFO, LogCategory_GENERIC, true);
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
250 ASSERT_TRUE(IsCategoryEnabled(LogLevel_INFO, LogCategory_GENERIC));
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
251 ASSERT_TRUE(IsCategoryEnabled(LogLevel_INFO, LogCategory_DICOM));
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
252 ASSERT_FALSE(IsCategoryEnabled(LogLevel_TRACE, LogCategory_GENERIC));
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
253 ASSERT_FALSE(IsCategoryEnabled(LogLevel_TRACE, LogCategory_DICOM));
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
254 ASSERT_FALSE(IsTraceLevelEnabled());
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
255 ASSERT_TRUE(IsInfoLevelEnabled());
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
256
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
257 SetCategoryEnabled(LogLevel_INFO, LogCategory_DICOM, false);
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
258 ASSERT_TRUE(IsCategoryEnabled(LogLevel_INFO, LogCategory_GENERIC));
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
259 ASSERT_FALSE(IsCategoryEnabled(LogLevel_INFO, LogCategory_DICOM));
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
260 ASSERT_FALSE(IsCategoryEnabled(LogLevel_TRACE, LogCategory_GENERIC));
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
261 ASSERT_FALSE(IsCategoryEnabled(LogLevel_TRACE, LogCategory_DICOM));
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
262 ASSERT_FALSE(IsTraceLevelEnabled());
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
263 ASSERT_TRUE(IsInfoLevelEnabled()); // "GENERIC" is still verbose
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
264
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
265 SetCategoryEnabled(LogLevel_INFO, LogCategory_GENERIC, false);
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
266 ASSERT_FALSE(IsCategoryEnabled(LogLevel_INFO, LogCategory_GENERIC));
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
267 ASSERT_FALSE(IsCategoryEnabled(LogLevel_INFO, LogCategory_DICOM));
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
268 ASSERT_FALSE(IsCategoryEnabled(LogLevel_TRACE, LogCategory_GENERIC));
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
269 ASSERT_FALSE(IsCategoryEnabled(LogLevel_TRACE, LogCategory_DICOM));
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
270 ASSERT_FALSE(IsTraceLevelEnabled());
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
271 ASSERT_FALSE(IsInfoLevelEnabled());
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
272
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
273
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
274 // Test the "category" setters at TRACE level
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
275 SetCategoryEnabled(LogLevel_TRACE, LogCategory_DICOM, true);
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
276 ASSERT_FALSE(IsCategoryEnabled(LogLevel_INFO, LogCategory_GENERIC));
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
277 ASSERT_TRUE(IsCategoryEnabled(LogLevel_INFO, LogCategory_DICOM));
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
278 ASSERT_FALSE(IsCategoryEnabled(LogLevel_TRACE, LogCategory_GENERIC));
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
279 ASSERT_TRUE(IsCategoryEnabled(LogLevel_TRACE, LogCategory_DICOM));
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
280 ASSERT_TRUE(IsTraceLevelEnabled());
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
281 ASSERT_TRUE(IsInfoLevelEnabled());
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
282
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
283 SetCategoryEnabled(LogLevel_TRACE, LogCategory_GENERIC, true);
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
284 ASSERT_TRUE(IsCategoryEnabled(LogLevel_INFO, LogCategory_GENERIC));
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
285 ASSERT_TRUE(IsCategoryEnabled(LogLevel_INFO, LogCategory_DICOM));
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
286 ASSERT_TRUE(IsCategoryEnabled(LogLevel_TRACE, LogCategory_GENERIC));
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
287 ASSERT_TRUE(IsCategoryEnabled(LogLevel_TRACE, LogCategory_DICOM));
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
288 ASSERT_TRUE(IsTraceLevelEnabled());
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
289 ASSERT_TRUE(IsInfoLevelEnabled());
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
290
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
291 SetCategoryEnabled(LogLevel_INFO, LogCategory_DICOM, false);
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
292 ASSERT_TRUE(IsCategoryEnabled(LogLevel_INFO, LogCategory_GENERIC));
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
293 ASSERT_FALSE(IsCategoryEnabled(LogLevel_INFO, LogCategory_DICOM));
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
294 ASSERT_TRUE(IsCategoryEnabled(LogLevel_TRACE, LogCategory_GENERIC));
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
295 ASSERT_FALSE(IsCategoryEnabled(LogLevel_TRACE, LogCategory_DICOM));
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
296 ASSERT_TRUE(IsTraceLevelEnabled()); // "GENERIC" is still at trace level
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
297 ASSERT_TRUE(IsInfoLevelEnabled());
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
298
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
299 SetCategoryEnabled(LogLevel_TRACE, LogCategory_GENERIC, false);
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
300 ASSERT_TRUE(IsCategoryEnabled(LogLevel_INFO, LogCategory_GENERIC));
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
301 ASSERT_FALSE(IsCategoryEnabled(LogLevel_INFO, LogCategory_DICOM));
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
302 ASSERT_FALSE(IsCategoryEnabled(LogLevel_TRACE, LogCategory_GENERIC));
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
303 ASSERT_FALSE(IsCategoryEnabled(LogLevel_TRACE, LogCategory_DICOM));
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
304 ASSERT_FALSE(IsTraceLevelEnabled());
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
305 ASSERT_TRUE(IsInfoLevelEnabled());
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
306
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
307 SetCategoryEnabled(LogLevel_INFO, LogCategory_GENERIC, false);
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
308 ASSERT_FALSE(IsCategoryEnabled(LogLevel_INFO, LogCategory_GENERIC));
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
309 ASSERT_FALSE(IsCategoryEnabled(LogLevel_INFO, LogCategory_DICOM));
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
310 ASSERT_FALSE(IsCategoryEnabled(LogLevel_TRACE, LogCategory_GENERIC));
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
311 ASSERT_FALSE(IsCategoryEnabled(LogLevel_TRACE, LogCategory_DICOM));
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
312 ASSERT_FALSE(IsTraceLevelEnabled());
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
313 ASSERT_FALSE(IsInfoLevelEnabled());
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
314
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
315
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
316
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
317 // Test the "macro" setters
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
318 EnableInfoLevel(true);
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
319 EnableTraceLevel(false);
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
320 ASSERT_FALSE(IsTraceLevelEnabled());
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
321 ASSERT_TRUE(IsInfoLevelEnabled());
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
322 ASSERT_TRUE(IsCategoryEnabled(LogLevel_ERROR, LogCategory_GENERIC));
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
323 ASSERT_TRUE(IsCategoryEnabled(LogLevel_ERROR, LogCategory_DICOM));
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
324 ASSERT_TRUE(IsCategoryEnabled(LogLevel_ERROR, LogCategory_SQLITE));
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
325 ASSERT_TRUE(IsCategoryEnabled(LogLevel_WARNING, LogCategory_GENERIC));
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
326 ASSERT_TRUE(IsCategoryEnabled(LogLevel_WARNING, LogCategory_DICOM));
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
327 ASSERT_TRUE(IsCategoryEnabled(LogLevel_WARNING, LogCategory_SQLITE));
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
328 ASSERT_TRUE(IsCategoryEnabled(LogLevel_INFO, LogCategory_GENERIC));
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
329 ASSERT_TRUE(IsCategoryEnabled(LogLevel_INFO, LogCategory_DICOM));
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
330 ASSERT_TRUE(IsCategoryEnabled(LogLevel_INFO, LogCategory_SQLITE));
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
331 ASSERT_FALSE(IsCategoryEnabled(LogLevel_TRACE, LogCategory_GENERIC));
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
332 ASSERT_FALSE(IsCategoryEnabled(LogLevel_TRACE, LogCategory_DICOM));
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
333 ASSERT_FALSE(IsCategoryEnabled(LogLevel_TRACE, LogCategory_SQLITE));
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
334
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
335 EnableInfoLevel(false);
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
336 EnableTraceLevel(true); // "--trace" implies "--verbose"
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
337 ASSERT_TRUE(IsTraceLevelEnabled());
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
338 ASSERT_TRUE(IsInfoLevelEnabled());
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
339 ASSERT_TRUE(IsCategoryEnabled(LogLevel_ERROR, LogCategory_GENERIC));
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
340 ASSERT_TRUE(IsCategoryEnabled(LogLevel_ERROR, LogCategory_DICOM));
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
341 ASSERT_TRUE(IsCategoryEnabled(LogLevel_ERROR, LogCategory_SQLITE));
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
342 ASSERT_TRUE(IsCategoryEnabled(LogLevel_WARNING, LogCategory_GENERIC));
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
343 ASSERT_TRUE(IsCategoryEnabled(LogLevel_WARNING, LogCategory_DICOM));
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
344 ASSERT_TRUE(IsCategoryEnabled(LogLevel_WARNING, LogCategory_SQLITE));
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
345 ASSERT_TRUE(IsCategoryEnabled(LogLevel_INFO, LogCategory_GENERIC));
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
346 ASSERT_TRUE(IsCategoryEnabled(LogLevel_INFO, LogCategory_DICOM));
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
347 ASSERT_TRUE(IsCategoryEnabled(LogLevel_INFO, LogCategory_SQLITE));
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
348 ASSERT_TRUE(IsCategoryEnabled(LogLevel_TRACE, LogCategory_GENERIC));
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
349 ASSERT_TRUE(IsCategoryEnabled(LogLevel_TRACE, LogCategory_DICOM));
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
350 ASSERT_TRUE(IsCategoryEnabled(LogLevel_TRACE, LogCategory_SQLITE));
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
351
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
352
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
353
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
354 // Back to normal
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
355 EnableInfoLevel(true);
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
356 EnableTraceLevel(false);
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
357 ASSERT_FALSE(IsTraceLevelEnabled());
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
358 ASSERT_TRUE(IsInfoLevelEnabled());
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
359 ASSERT_TRUE(IsCategoryEnabled(LogLevel_INFO, LogCategory_SQLITE));
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
360 ASSERT_FALSE(IsCategoryEnabled(LogLevel_TRACE, LogCategory_SQLITE));
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
361 }
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
362
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
363
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
364 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
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 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
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 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
369 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
370 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
371 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
372 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
373 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
374 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
375 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
376 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
377
4294
0923247e69f6 log categories: rest -> http + added lua & jobs
Alain Mazy <alain@mazy.be>
parents: 4276
diff changeset
378 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
379
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 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
381 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
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 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
384 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
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
4294
0923247e69f6 log categories: rest -> http + added lua & jobs
Alain Mazy <alain@mazy.be>
parents: 4276
diff changeset
387 ASSERT_EQ(7u, s.size());
4276
68e24935f258 fix for visual studio
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4275
diff changeset
388 ASSERT_TRUE(s.find("generic") != s.end());
68e24935f258 fix for visual studio
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4275
diff changeset
389 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
390 ASSERT_TRUE(s.find("http") != s.end());
4276
68e24935f258 fix for visual studio
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4275
diff changeset
391 ASSERT_TRUE(s.find("sqlite") != s.end());
68e24935f258 fix for visual studio
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4275
diff changeset
392 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
393 ASSERT_TRUE(s.find("lua") != s.end());
0923247e69f6 log categories: rest -> http + added lua & jobs
Alain Mazy <alain@mazy.be>
parents: 4276
diff changeset
394 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
395
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
396 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
397
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 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
399 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
400 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
401 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
402 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
403 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
404 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
405 }