If launched with debug severity allow our subprocess to write to stdout/stderr

This commit is contained in:
Simon Fels 2017-05-23 08:29:41 +02:00
commit 190d8690d3
3 changed files with 10 additions and 1 deletions

View file

@ -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();

View file

@ -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<Location>& loc) override {
if (!initialized_) Init();

View file

@ -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>& location) = 0;