diff --git a/src/common/logging.cpp b/src/common/logging.cpp index 6950dd26..d8e9b892 100644 --- a/src/common/logging.cpp +++ b/src/common/logging.cpp @@ -72,7 +72,12 @@ Logger Logger::create_from_environment(std::string prefix) { if (log_file->is_open()) { return Logger(log_file, verbosity_level, prefix); } else { - return Logger(std::shared_ptr(&std::cerr, [](auto) {}), + // For STDERR we sadly can't just use `std::cerr`. In the group process + // we need to capture all output generated by the process itself, and + // the only way to do this is by reopening the STDERR and STDOUT streams + // to a pipe. Luckily `/dev/stderr` stays unaffected, so we can still + // write there without causing infinite loops. + return Logger(std::make_shared("/dev/stderr"), verbosity_level, prefix); } }