agent: Only show ttrpc logs for trace log level

Only display the `ttrpc` crate log output when full logging
(trace level) is enabled.

This is a slight abuse of log levels but provides developers and testers
what they need whilst also keeping the logs relatively quiet for the
default info log level (the `ttrpc` crate logging is a bit "chatty").

Signed-off-by: James O. D. Hunt <james.o.hunt@intel.com>
This commit is contained in:
James O. D. Hunt 2020-10-27 11:21:49 +00:00
parent 21cd7ad172
commit 8907a33907
3 changed files with 8 additions and 2 deletions

1
src/agent/Cargo.lock generated
View File

@ -375,6 +375,7 @@ dependencies = [
"cgroups",
"lazy_static",
"libc",
"log",
"logging",
"netlink",
"nix 0.17.0",

View File

@ -30,6 +30,7 @@ slog-scope = "4.1.2"
# Redirect ttrpc log calls
slog-stdlog = "4.0.0"
log = "0.4.11"
# for testing
tempfile = "3.1.0"

View File

@ -198,8 +198,12 @@ fn main() -> Result<()> {
// which is required to satisfy the the lifetime constraints of the auto-generated gRPC code.
let _guard = slog_scope::set_global_logger(logger.new(o!("subsystem" => "rpc")));
// Redirect ttrpc log calls to slog
let _log_guard = slog_stdlog::init()?;
let mut _log_guard: Result<(), log::SetLoggerError> = Ok(());
if config.log_level == slog::Level::Trace {
// Redirect ttrpc log calls to slog iff full debug requested
_log_guard = Ok(slog_stdlog::init().map_err(|e| e)?);
}
start_sandbox(&logger, &config, init_mode)?;