diff --git a/src/anbox/cmds/launch.cpp b/src/anbox/cmds/launch.cpp index 69830aa..1d8aa82 100644 --- a/src/anbox/cmds/launch.cpp +++ b/src/anbox/cmds/launch.cpp @@ -130,7 +130,11 @@ anbox::cmds::Launch::Launch() } 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 grandchild = core::posix::exec(exe_path, args, env, flags); grandchild.dont_kill_on_cleanup(); diff --git a/src/anbox/logger.cpp b/src/anbox/logger.cpp index f59803d..2e184d8 100644 --- a/src/anbox/logger.cpp +++ b/src/anbox/logger.cpp @@ -64,6 +64,10 @@ struct BoostLogLogger : public anbox::Logger { severity_ = severity; } + Severity GetSeverity() override { + return severity_; + } + void Log(Severity severity, const std::string& message, const boost::optional& loc) override { if (!initialized_) Init(); diff --git a/src/anbox/logger.h b/src/anbox/logger.h index 6e797b6..e9b06e4 100644 --- a/src/anbox/logger.h +++ b/src/anbox/logger.h @@ -51,6 +51,7 @@ class Logger : public DoNotCopyOrMove { bool SetSeverityFromString(const std::string &severity); virtual void SetSeverity(const Severity& severity) = 0; + virtual Severity GetSeverity() = 0; virtual void Log(Severity severity, const std::string& message, const boost::optional& location) = 0;