annotate OrthancFramework/UnitTestsSources/LoggingTests.cpp @ 4660:4e81412ead0a

in DICOMweb JSON, BulkDataURI is forced for sequences and pixel data
author Sebastien Jodogne <s.jodogne@gmail.com>
date Fri, 07 May 2021 12:46:06 +0200
parents d9473bd5ed43
children 7053502fbf97
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
4437
d9473bd5ed43 upgrade to year 2021
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4325
diff changeset
5 * Copyright (C) 2017-2021 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
4325
b96aedfa8cc1 unit tests now running in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4299
diff changeset
132 #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
133 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
134 {
54cdad5a7228 Added a public function that will use emscripten-specific logging functions when using its SDK + scaffolding 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 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
136
4270
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
137 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
138
54cdad5a7228 Added a public function that will use emscripten-specific logging functions when using its SDK + scaffolding 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 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
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 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
142 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
143
54cdad5a7228 Added a public function that will use emscripten-specific logging functions when using its SDK + scaffolding 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 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
145 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
146
54cdad5a7228 Added a public function that will use emscripten-specific logging functions when using its SDK + scaffolding 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 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
148 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
149
4270
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
150 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
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 {
54cdad5a7228 Added a public function that will use emscripten-specific logging functions when using its SDK + scaffolding 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 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
154 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
155 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
156 testErrorStream.str("");
54cdad5a7228 Added a public function that will use emscripten-specific logging functions when using its SDK + scaffolding work. Build and UT OK on msvc15 x64. Not actually tested under *nix or emscripten yet
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
157 testErrorStream.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
158 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
159 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
160 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
161 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
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
54cdad5a7228 Added a public function that will use emscripten-specific logging functions when using its SDK + scaffolding 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 // 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
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 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
167 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
168 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
169 testErrorStream.str("");
54cdad5a7228 Added a public function that will use emscripten-specific logging functions when using its SDK + scaffolding work. Build and UT OK on msvc15 x64. Not actually tested under *nix or emscripten yet
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
170 testErrorStream.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
171 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
172 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
173 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
174 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
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 {
54cdad5a7228 Added a public function that will use emscripten-specific logging functions when using its SDK + scaffolding 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 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
179 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
180 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
181 testWarningStream.str("");
54cdad5a7228 Added a public function that will use emscripten-specific logging functions when using its SDK + scaffolding work. Build and UT OK on msvc15 x64. Not actually tested under *nix or emscripten yet
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
182 testWarningStream.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
183 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
184 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
185 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
186 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
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 {
54cdad5a7228 Added a public function that will use emscripten-specific logging functions when using its SDK + scaffolding 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 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
191 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
192 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
193 testInfoStream.str("");
54cdad5a7228 Added a public function that will use emscripten-specific logging functions when using its SDK + scaffolding work. Build and UT OK on msvc15 x64. Not actually tested under *nix or emscripten yet
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
194 testInfoStream.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
195 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
196 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
197 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
198 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
199 }
4270
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
200
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
201 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
202 }
4325
b96aedfa8cc1 unit tests now running in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4299
diff changeset
203 #endif
4270
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
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 TEST(Logging, Categories)
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 using namespace Orthanc::Logging;
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 // Unit tests are running in "--verbose" mode (not "--trace")
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
212 ASSERT_FALSE(IsTraceLevelEnabled());
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
213 ASSERT_TRUE(IsInfoLevelEnabled());
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
214 ASSERT_TRUE(IsCategoryEnabled(LogLevel_INFO, LogCategory_SQLITE));
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
215 ASSERT_FALSE(IsCategoryEnabled(LogLevel_TRACE, LogCategory_SQLITE));
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
216
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
217 // Cannot modify categories for ERROR and WARNING
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
218 ASSERT_THROW(SetCategoryEnabled(LogLevel_ERROR, LogCategory_GENERIC, true),
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 ASSERT_THROW(SetCategoryEnabled(LogLevel_WARNING, LogCategory_GENERIC, false),
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
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
223
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
224 EnableInfoLevel(false);
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
225 EnableTraceLevel(false);
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
226 ASSERT_FALSE(IsTraceLevelEnabled());
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
227 ASSERT_FALSE(IsInfoLevelEnabled());
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
228 ASSERT_TRUE(IsCategoryEnabled(LogLevel_ERROR, LogCategory_GENERIC));
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
229 ASSERT_TRUE(IsCategoryEnabled(LogLevel_ERROR, LogCategory_DICOM));
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
230 ASSERT_TRUE(IsCategoryEnabled(LogLevel_ERROR, LogCategory_SQLITE));
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
231 ASSERT_TRUE(IsCategoryEnabled(LogLevel_WARNING, LogCategory_GENERIC));
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
232 ASSERT_TRUE(IsCategoryEnabled(LogLevel_WARNING, LogCategory_DICOM));
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
233 ASSERT_TRUE(IsCategoryEnabled(LogLevel_WARNING, LogCategory_SQLITE));
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
234 ASSERT_FALSE(IsCategoryEnabled(LogLevel_INFO, LogCategory_GENERIC));
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
235 ASSERT_FALSE(IsCategoryEnabled(LogLevel_INFO, LogCategory_DICOM));
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
236 ASSERT_FALSE(IsCategoryEnabled(LogLevel_INFO, LogCategory_SQLITE));
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
237 ASSERT_FALSE(IsCategoryEnabled(LogLevel_TRACE, LogCategory_GENERIC));
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
238 ASSERT_FALSE(IsCategoryEnabled(LogLevel_TRACE, LogCategory_DICOM));
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
239 ASSERT_FALSE(IsCategoryEnabled(LogLevel_TRACE, LogCategory_SQLITE));
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
240
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
241
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
242 // Test the "category" setters at INFO level
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
243 SetCategoryEnabled(LogLevel_INFO, LogCategory_DICOM, true);
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
244 ASSERT_FALSE(IsCategoryEnabled(LogLevel_INFO, LogCategory_GENERIC));
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
245 ASSERT_TRUE(IsCategoryEnabled(LogLevel_INFO, LogCategory_DICOM));
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
246 ASSERT_FALSE(IsCategoryEnabled(LogLevel_TRACE, LogCategory_GENERIC));
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
247 ASSERT_FALSE(IsCategoryEnabled(LogLevel_TRACE, LogCategory_DICOM));
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
248 ASSERT_FALSE(IsTraceLevelEnabled());
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
249 ASSERT_TRUE(IsInfoLevelEnabled()); // At least one category is verbose
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
250
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
251 SetCategoryEnabled(LogLevel_INFO, LogCategory_GENERIC, true);
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
252 ASSERT_TRUE(IsCategoryEnabled(LogLevel_INFO, LogCategory_GENERIC));
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
253 ASSERT_TRUE(IsCategoryEnabled(LogLevel_INFO, LogCategory_DICOM));
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
254 ASSERT_FALSE(IsCategoryEnabled(LogLevel_TRACE, LogCategory_GENERIC));
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
255 ASSERT_FALSE(IsCategoryEnabled(LogLevel_TRACE, LogCategory_DICOM));
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
256 ASSERT_FALSE(IsTraceLevelEnabled());
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
257 ASSERT_TRUE(IsInfoLevelEnabled());
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
258
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
259 SetCategoryEnabled(LogLevel_INFO, LogCategory_DICOM, false);
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
260 ASSERT_TRUE(IsCategoryEnabled(LogLevel_INFO, LogCategory_GENERIC));
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
261 ASSERT_FALSE(IsCategoryEnabled(LogLevel_INFO, LogCategory_DICOM));
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
262 ASSERT_FALSE(IsCategoryEnabled(LogLevel_TRACE, LogCategory_GENERIC));
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
263 ASSERT_FALSE(IsCategoryEnabled(LogLevel_TRACE, LogCategory_DICOM));
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
264 ASSERT_FALSE(IsTraceLevelEnabled());
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
265 ASSERT_TRUE(IsInfoLevelEnabled()); // "GENERIC" is still verbose
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
266
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
267 SetCategoryEnabled(LogLevel_INFO, LogCategory_GENERIC, false);
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
268 ASSERT_FALSE(IsCategoryEnabled(LogLevel_INFO, LogCategory_GENERIC));
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
269 ASSERT_FALSE(IsCategoryEnabled(LogLevel_INFO, LogCategory_DICOM));
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
270 ASSERT_FALSE(IsCategoryEnabled(LogLevel_TRACE, LogCategory_GENERIC));
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
271 ASSERT_FALSE(IsCategoryEnabled(LogLevel_TRACE, LogCategory_DICOM));
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
272 ASSERT_FALSE(IsTraceLevelEnabled());
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
273 ASSERT_FALSE(IsInfoLevelEnabled());
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
274
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
275
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
276 // Test the "category" setters at TRACE level
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
277 SetCategoryEnabled(LogLevel_TRACE, LogCategory_DICOM, true);
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
278 ASSERT_FALSE(IsCategoryEnabled(LogLevel_INFO, LogCategory_GENERIC));
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
279 ASSERT_TRUE(IsCategoryEnabled(LogLevel_INFO, LogCategory_DICOM));
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
280 ASSERT_FALSE(IsCategoryEnabled(LogLevel_TRACE, LogCategory_GENERIC));
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
281 ASSERT_TRUE(IsCategoryEnabled(LogLevel_TRACE, LogCategory_DICOM));
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
282 ASSERT_TRUE(IsTraceLevelEnabled());
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
283 ASSERT_TRUE(IsInfoLevelEnabled());
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
284
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
285 SetCategoryEnabled(LogLevel_TRACE, LogCategory_GENERIC, true);
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
286 ASSERT_TRUE(IsCategoryEnabled(LogLevel_INFO, LogCategory_GENERIC));
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
287 ASSERT_TRUE(IsCategoryEnabled(LogLevel_INFO, LogCategory_DICOM));
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
288 ASSERT_TRUE(IsCategoryEnabled(LogLevel_TRACE, LogCategory_GENERIC));
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
289 ASSERT_TRUE(IsCategoryEnabled(LogLevel_TRACE, LogCategory_DICOM));
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
290 ASSERT_TRUE(IsTraceLevelEnabled());
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
291 ASSERT_TRUE(IsInfoLevelEnabled());
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
292
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
293 SetCategoryEnabled(LogLevel_INFO, LogCategory_DICOM, false);
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
294 ASSERT_TRUE(IsCategoryEnabled(LogLevel_INFO, LogCategory_GENERIC));
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
295 ASSERT_FALSE(IsCategoryEnabled(LogLevel_INFO, LogCategory_DICOM));
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
296 ASSERT_TRUE(IsCategoryEnabled(LogLevel_TRACE, LogCategory_GENERIC));
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
297 ASSERT_FALSE(IsCategoryEnabled(LogLevel_TRACE, LogCategory_DICOM));
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
298 ASSERT_TRUE(IsTraceLevelEnabled()); // "GENERIC" is still at trace level
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
299 ASSERT_TRUE(IsInfoLevelEnabled());
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
300
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
301 SetCategoryEnabled(LogLevel_TRACE, LogCategory_GENERIC, false);
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
302 ASSERT_TRUE(IsCategoryEnabled(LogLevel_INFO, LogCategory_GENERIC));
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
303 ASSERT_FALSE(IsCategoryEnabled(LogLevel_INFO, LogCategory_DICOM));
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
304 ASSERT_FALSE(IsCategoryEnabled(LogLevel_TRACE, LogCategory_GENERIC));
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
305 ASSERT_FALSE(IsCategoryEnabled(LogLevel_TRACE, LogCategory_DICOM));
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
306 ASSERT_FALSE(IsTraceLevelEnabled());
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
307 ASSERT_TRUE(IsInfoLevelEnabled());
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
308
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
309 SetCategoryEnabled(LogLevel_INFO, LogCategory_GENERIC, false);
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
310 ASSERT_FALSE(IsCategoryEnabled(LogLevel_INFO, LogCategory_GENERIC));
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
311 ASSERT_FALSE(IsCategoryEnabled(LogLevel_INFO, LogCategory_DICOM));
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
312 ASSERT_FALSE(IsCategoryEnabled(LogLevel_TRACE, LogCategory_GENERIC));
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
313 ASSERT_FALSE(IsCategoryEnabled(LogLevel_TRACE, LogCategory_DICOM));
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
314 ASSERT_FALSE(IsTraceLevelEnabled());
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
315 ASSERT_FALSE(IsInfoLevelEnabled());
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
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 // Test the "macro" setters
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
320 EnableInfoLevel(true);
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
321 EnableTraceLevel(false);
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
322 ASSERT_FALSE(IsTraceLevelEnabled());
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
323 ASSERT_TRUE(IsInfoLevelEnabled());
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
324 ASSERT_TRUE(IsCategoryEnabled(LogLevel_ERROR, LogCategory_GENERIC));
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
325 ASSERT_TRUE(IsCategoryEnabled(LogLevel_ERROR, LogCategory_DICOM));
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
326 ASSERT_TRUE(IsCategoryEnabled(LogLevel_ERROR, LogCategory_SQLITE));
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
327 ASSERT_TRUE(IsCategoryEnabled(LogLevel_WARNING, LogCategory_GENERIC));
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
328 ASSERT_TRUE(IsCategoryEnabled(LogLevel_WARNING, LogCategory_DICOM));
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
329 ASSERT_TRUE(IsCategoryEnabled(LogLevel_WARNING, LogCategory_SQLITE));
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
330 ASSERT_TRUE(IsCategoryEnabled(LogLevel_INFO, LogCategory_GENERIC));
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
331 ASSERT_TRUE(IsCategoryEnabled(LogLevel_INFO, LogCategory_DICOM));
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
332 ASSERT_TRUE(IsCategoryEnabled(LogLevel_INFO, LogCategory_SQLITE));
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
333 ASSERT_FALSE(IsCategoryEnabled(LogLevel_TRACE, LogCategory_GENERIC));
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
334 ASSERT_FALSE(IsCategoryEnabled(LogLevel_TRACE, LogCategory_DICOM));
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
335 ASSERT_FALSE(IsCategoryEnabled(LogLevel_TRACE, LogCategory_SQLITE));
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
336
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
337 EnableInfoLevel(false);
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
338 EnableTraceLevel(true); // "--trace" implies "--verbose"
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
339 ASSERT_TRUE(IsTraceLevelEnabled());
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
340 ASSERT_TRUE(IsInfoLevelEnabled());
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
341 ASSERT_TRUE(IsCategoryEnabled(LogLevel_ERROR, LogCategory_GENERIC));
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
342 ASSERT_TRUE(IsCategoryEnabled(LogLevel_ERROR, LogCategory_DICOM));
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
343 ASSERT_TRUE(IsCategoryEnabled(LogLevel_ERROR, LogCategory_SQLITE));
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
344 ASSERT_TRUE(IsCategoryEnabled(LogLevel_WARNING, LogCategory_GENERIC));
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
345 ASSERT_TRUE(IsCategoryEnabled(LogLevel_WARNING, LogCategory_DICOM));
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
346 ASSERT_TRUE(IsCategoryEnabled(LogLevel_WARNING, LogCategory_SQLITE));
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
347 ASSERT_TRUE(IsCategoryEnabled(LogLevel_INFO, LogCategory_GENERIC));
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
348 ASSERT_TRUE(IsCategoryEnabled(LogLevel_INFO, LogCategory_DICOM));
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
349 ASSERT_TRUE(IsCategoryEnabled(LogLevel_INFO, LogCategory_SQLITE));
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
350 ASSERT_TRUE(IsCategoryEnabled(LogLevel_TRACE, LogCategory_GENERIC));
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
351 ASSERT_TRUE(IsCategoryEnabled(LogLevel_TRACE, LogCategory_DICOM));
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
352 ASSERT_TRUE(IsCategoryEnabled(LogLevel_TRACE, LogCategory_SQLITE));
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
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 // Back to normal
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
357 EnableInfoLevel(true);
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
358 EnableTraceLevel(false);
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
359 ASSERT_FALSE(IsTraceLevelEnabled());
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
360 ASSERT_TRUE(IsInfoLevelEnabled());
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
361 ASSERT_TRUE(IsCategoryEnabled(LogLevel_INFO, LogCategory_SQLITE));
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
362 ASSERT_FALSE(IsCategoryEnabled(LogLevel_TRACE, LogCategory_SQLITE));
251a8b07fa37 logging categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
363 }
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
364
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 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
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 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
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 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
371 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
372 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
373 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
374 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
375 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
376 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
377 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
378 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
379
4294
0923247e69f6 log categories: rest -> http + added lua & jobs
Alain Mazy <alain@mazy.be>
parents: 4276
diff changeset
380 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
381
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 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
383 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
384 {
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 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
386 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
387 }
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
4294
0923247e69f6 log categories: rest -> http + added lua & jobs
Alain Mazy <alain@mazy.be>
parents: 4276
diff changeset
389 ASSERT_EQ(7u, s.size());
4276
68e24935f258 fix for visual studio
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4275
diff changeset
390 ASSERT_TRUE(s.find("generic") != s.end());
68e24935f258 fix for visual studio
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4275
diff changeset
391 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
392 ASSERT_TRUE(s.find("http") != s.end());
4276
68e24935f258 fix for visual studio
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4275
diff changeset
393 ASSERT_TRUE(s.find("sqlite") != s.end());
68e24935f258 fix for visual studio
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4275
diff changeset
394 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
395 ASSERT_TRUE(s.find("lua") != s.end());
0923247e69f6 log categories: rest -> http + added lua & jobs
Alain Mazy <alain@mazy.be>
parents: 4276
diff changeset
396 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
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_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
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_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
401 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
402 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
403 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
404 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
405 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
406 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
407 }