mirror of
https://github.com/robbert-vdh/yabridge.git
synced 2026-05-07 03:50:11 +02:00
Fall back to /dev/stderr instead of std::cerr
This allows us to remap STDIO internally in the group process.
This commit is contained in:
@@ -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::ostream>(&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<std::ofstream>("/dev/stderr"),
|
||||
verbosity_level, prefix);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user