From 3431752649c14e1b8a920247ee466cfc793eb664 Mon Sep 17 00:00:00 2001 From: Erik Frojdh Date: Tue, 3 Mar 2020 17:01:45 +0100 Subject: [PATCH] WIP --- .clang-tidy | 3 ++- slsSupportLib/include/logger.h | 26 ++++++++++++++++++-------- slsSupportLib/tests/CMakeLists.txt | 1 + slsSupportLib/tests/test-logger.cpp | 16 ++++++++++++++++ 4 files changed, 37 insertions(+), 9 deletions(-) create mode 100644 slsSupportLib/tests/test-logger.cpp diff --git a/.clang-tidy b/.clang-tidy index eff429960..6e94d11e4 100644 --- a/.clang-tidy +++ b/.clang-tidy @@ -17,7 +17,8 @@ Checks: '*, -google-runtime-references, -google-readability-todo, -google-readability-braces-around-statements, - -modernize-use-trailing-return-type' + -modernize-use-trailing-return-type, + -readability-isolate-declaration' HeaderFilterRegex: \.h AnalyzeTemporaryDtors: false diff --git a/slsSupportLib/include/logger.h b/slsSupportLib/include/logger.h index 5239cc0f2..c5e8933f3 100755 --- a/slsSupportLib/include/logger.h +++ b/slsSupportLib/include/logger.h @@ -5,7 +5,7 @@ #include #include #include - +#include #ifdef FIFODEBUG @@ -22,8 +22,8 @@ #endif -#define STRINGIFY(x) #x -#define TOSTRING(x) STRINGIFY(x) +// #define STRINGIFY(x) #x +// #define TOSTRING(x) STRINGIFY(x) #define MYCONCAT(x,y) #define __AT__ std::string(__FILE__) + std::string("::") + std::string(__func__) + std::string("(): ") #define __SHORT_FORM_OF_FILE__ \ @@ -162,13 +162,23 @@ inline FILE*& Output2FILE::Stream() return pStream; } +// inline void Output2FILE::Output(const std::string& msg) +// { +// FILE* pStream = Stream(); +// if (!pStream) +// return; +// fprintf(pStream, "%s", msg.c_str()); +// fflush(pStream); +// } + inline void Output2FILE::Output(const std::string& msg) { - FILE* pStream = Stream(); - if (!pStream) - return; - fprintf(pStream, "%s", msg.c_str()); - fflush(pStream); + std::cout << msg; + // FILE* pStream = Stream(); + // if (!pStream) + // return; + // fprintf(pStream, "%s", msg.c_str()); + // fflush(pStream); } inline void Output2FILE::Output(const std::string& msg, TLogLevel level) diff --git a/slsSupportLib/tests/CMakeLists.txt b/slsSupportLib/tests/CMakeLists.txt index bb84225d5..8832c3315 100755 --- a/slsSupportLib/tests/CMakeLists.txt +++ b/slsSupportLib/tests/CMakeLists.txt @@ -9,4 +9,5 @@ target_sources(tests PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/test-ToString.cpp ${CMAKE_CURRENT_SOURCE_DIR}/test-TypeTraits.cpp ${CMAKE_CURRENT_SOURCE_DIR}/test-UdpRxSocket.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/test-logger.cpp ) \ No newline at end of file diff --git a/slsSupportLib/tests/test-logger.cpp b/slsSupportLib/tests/test-logger.cpp new file mode 100644 index 000000000..7d6439b6b --- /dev/null +++ b/slsSupportLib/tests/test-logger.cpp @@ -0,0 +1,16 @@ +#include "catch.hpp" +#include "logger.h" + +#include +#include +TEST_CASE("fail"){ + + FILE_LOG(logINFO) << "A message"; + + + + + // CHECK(false); + + +} \ No newline at end of file