From 1a787a5b87f29e4800427259cc6ca8dd4fabd786 Mon Sep 17 00:00:00 2001 From: shareong <740310627@qq.com> Date: Fri, 15 Mar 2024 13:08:25 +0800 Subject: [PATCH] update log format --- bcos-utilities/BoostLogInitializer.h | 12 +++++++++++- cmake/CompilerSettings.cmake | 1 - 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/bcos-utilities/BoostLogInitializer.h b/bcos-utilities/BoostLogInitializer.h index 3651f85..b79da1a 100644 --- a/bcos-utilities/BoostLogInitializer.h +++ b/bcos-utilities/BoostLogInitializer.h @@ -35,6 +35,8 @@ #include #include #include +#include +#include namespace bcos { @@ -95,7 +97,15 @@ class BoostLogInitializer { try { - auto formatter = boost::log::parse_formatter(format); + // replace ~ with %, because only % is used as escape character in boost log + std::string realFormat(format); + char toReplace = '~'; + char replacement = '%'; + std::replace_if( + realFormat.begin(), realFormat.end(), + [&toReplace](char c) { return c == toReplace; }, replacement); + + auto formatter = boost::log::parse_formatter(realFormat); _sink->set_formatter(formatter); } catch (std::exception& e) diff --git a/cmake/CompilerSettings.cmake b/cmake/CompilerSettings.cmake index 17c9e73..989aae8 100644 --- a/cmake/CompilerSettings.cmake +++ b/cmake/CompilerSettings.cmake @@ -40,7 +40,6 @@ if(("${CMAKE_CXX_COMPILER_ID}" MATCHES "GNU") OR("${CMAKE_CXX_COMPILER_ID}" MATC add_compile_options(-Wno-unused-variable) add_compile_options(-Wno-unknown-pragmas) add_compile_options(-Wno-deprecated-declarations) - add_compile_options(-Wno-error=deprecated-declarations) add_compile_options(-fno-omit-frame-pointer) add_compile_options(-Wno-error=strict-aliasing)