# HG changeset patch # User Sebastien Jodogne # Date 1591598863 -7200 # Node ID 2d4427ca4be9bc2b803478e31c769a8bd076bc5f # Parent 884b55ce01f6ecbcbcb2b8ab8496891f96478e42 removed Core/LoggingUtils.h diff -r 884b55ce01f6 -r 2d4427ca4be9 Core/LoggingUtils.h --- a/Core/LoggingUtils.h Sat Jun 06 14:50:21 2020 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,30 +0,0 @@ -#include -#include - -namespace Orthanc -{ - namespace Logging - { - - /** - std::streambuf subclass used in FunctionCallingStream - */ - template - class FuncStreamBuf : public std::stringbuf - { - public: - FuncStreamBuf(T func) : func_(func) {} - - virtual int sync() - { - std::string text = this->str(); - const char* buf = text.c_str(); - func_(buf); - this->str(""); - return 0; - } - private: - T func_; - }; - } -} \ No newline at end of file diff -r 884b55ce01f6 -r 2d4427ca4be9 UnitTestsSources/LoggingTests.cpp --- a/UnitTestsSources/LoggingTests.cpp Sat Jun 06 14:50:21 2020 +0200 +++ b/UnitTestsSources/LoggingTests.cpp Mon Jun 08 08:47:43 2020 +0200 @@ -41,7 +41,6 @@ #include #include "../Core/Logging.h" -#include "../Core/LoggingUtils.h" using namespace Orthanc::Logging; @@ -64,19 +63,19 @@ } /** -Extracts the log line payload + Extracts the log line payload -"E0423 16:55:43.001194 LoggingTests.cpp:102] Foo bar?\n" ---> -"Foo bar" + "E0423 16:55:43.001194 LoggingTests.cpp:102] Foo bar?\n" + --> + "Foo bar" -If the log line cannot be matched, the function returns false. + If the log line cannot be matched, the function returns false. */ #define EOLSTRING "\n" static bool GetLogLinePayload(std::string& payload, - const std::string& logLine) + const std::string& logLine) { const char* regexStr = "[A-Z][0-9]{4} [0-9]{2}:[0-9]{2}:[0-9]{2}.[0-9]{6} " "[a-zA-Z\\.\\-_]+:[0-9]+\\] (.*)" EOLSTRING "$"; @@ -100,6 +99,7 @@ } } + namespace { class LoggingMementoScope @@ -114,8 +114,31 @@ Orthanc::Logging::Reset(); } }; + + + /** + * std::streambuf subclass used in FunctionCallingStream + **/ + template + class FuncStreamBuf : public std::stringbuf + { + public: + FuncStreamBuf(T func) : func_(func) {} + + virtual int sync() + { + std::string text = this->str(); + const char* buf = text.c_str(); + func_(buf); + this->str(""); + return 0; + } + private: + T func_; + }; } + TEST(FuncStreamBuf, BasicTest) { LoggingMementoScope loggingConfiguration;