Skip to content

Commit

Permalink
update log format
Browse files Browse the repository at this point in the history
  • Loading branch information
Shareong committed Mar 15, 2024
1 parent 67b4adc commit 1a787a5
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
12 changes: 11 additions & 1 deletion bcos-utilities/BoostLogInitializer.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@
#include <boost/property_tree/ini_parser.hpp>
#include <boost/property_tree/ptree.hpp>
#include <boost/shared_ptr.hpp>
#include <algorithm>
#include <string>

namespace bcos
{
Expand Down Expand Up @@ -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)
Expand Down
1 change: 0 additions & 1 deletion cmake/CompilerSettings.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down

0 comments on commit 1a787a5

Please sign in to comment.