mirror of
https://github.com/robbert-vdh/yabridge.git
synced 2026-05-09 20:29:10 +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()) {
|
if (log_file->is_open()) {
|
||||||
return Logger(log_file, verbosity_level, prefix);
|
return Logger(log_file, verbosity_level, prefix);
|
||||||
} else {
|
} 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);
|
verbosity_level, prefix);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user