A spdlog formatter which wraps another formatter and makes sure that if there are new lines (\n) in the log message, that the log message is still properly indented.
Multiline log message with normal pattern formatter:
std::shared_ptr<spdlog::logger> logger =
spdlog::stdout_color_mt("logger_name");
logger->set_level(spdlog::level::trace);
SPDLOG_LOGGER_TRACE(logger, "hello\nworld");
Output:
[2020-10-08 20:45:54.021] [logger_name] [trace] [mesh_factory_tests.cc:77] hello
world
std::shared_ptr<spdlog::logger> logger =
spdlog::stdout_color_mt("logger_name");
logger->set_formatter(std::make_unique<lf::base::LineFeedFormatter>(
std::make_unique<spdlog::pattern_formatter>()));
logger->set_level(spdlog::level::trace);
SPDLOG_LOGGER_TRACE(logger, "hello\nworld");
Output:
[2020-10-08 20:47:15.781] [logger_name] [trace] [mesh_factory_tests.cc:81] hello
world
Definition at line 75 of file spdlog_utils.h.