Skip to content
This repository has been archived by the owner on May 21, 2024. It is now read-only.

logging: Allow logger to use STDERR #1457

Merged
merged 1 commit into from
Nov 26, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion src/libaktualizr/logging/default_log_sink.cc
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,11 @@ static void color_fmt(boost::log::record_view const& rec, boost::log::formatting
}

void logger_init_sink(bool use_colors = false) {
auto sink = boost::log::add_console_log(std::cout, boost::log::keywords::format = "%Message%",
auto stream = &std::cerr;
if (getenv("LOG_STDERR") == nullptr) {
stream = &std::cout;
}
auto sink = boost::log::add_console_log(*stream, boost::log::keywords::format = "%Message%",
boost::log::keywords::auto_flush = true);
if (use_colors) {
sink->set_formatter(&color_fmt);
Expand Down