If launched with debug severity allow our subprocess to write to stdout/stderr
This commit is contained in:
parent
e04dd4bcf6
commit
190d8690d3
3 changed files with 10 additions and 1 deletions
|
|
@ -130,7 +130,11 @@ anbox::cmds::Launch::Launch()
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const auto flags = core::posix::StandardStream::stdout | core::posix::StandardStream::stderr;
|
auto flags = core::posix::StandardStream::stdout | core::posix::StandardStream::stderr;
|
||||||
|
// If we have logging enable in debug mode then we allow the child process
|
||||||
|
// to print to stdout/stderr too.
|
||||||
|
if (Log().GetSeverity() == Logger::Severity::kDebug)
|
||||||
|
flags = core::posix::StandardStream::empty;
|
||||||
auto child = core::posix::fork([&]() {
|
auto child = core::posix::fork([&]() {
|
||||||
auto grandchild = core::posix::exec(exe_path, args, env, flags);
|
auto grandchild = core::posix::exec(exe_path, args, env, flags);
|
||||||
grandchild.dont_kill_on_cleanup();
|
grandchild.dont_kill_on_cleanup();
|
||||||
|
|
|
||||||
|
|
@ -64,6 +64,10 @@ struct BoostLogLogger : public anbox::Logger {
|
||||||
severity_ = severity;
|
severity_ = severity;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Severity GetSeverity() override {
|
||||||
|
return severity_;
|
||||||
|
}
|
||||||
|
|
||||||
void Log(Severity severity, const std::string& message, const boost::optional<Location>& loc) override {
|
void Log(Severity severity, const std::string& message, const boost::optional<Location>& loc) override {
|
||||||
if (!initialized_) Init();
|
if (!initialized_) Init();
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -51,6 +51,7 @@ class Logger : public DoNotCopyOrMove {
|
||||||
|
|
||||||
bool SetSeverityFromString(const std::string &severity);
|
bool SetSeverityFromString(const std::string &severity);
|
||||||
virtual void SetSeverity(const Severity& severity) = 0;
|
virtual void SetSeverity(const Severity& severity) = 0;
|
||||||
|
virtual Severity GetSeverity() = 0;
|
||||||
|
|
||||||
virtual void Log(Severity severity, const std::string& message,
|
virtual void Log(Severity severity, const std::string& message,
|
||||||
const boost::optional<Location>& location) = 0;
|
const boost::optional<Location>& location) = 0;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue