agent: Log ttrpc messages

The `ttrpc` crate uses the `log` crate for logging. But the agent uses
the `slog` crate. This means that currently, all `ttrpc` log messages
are being discarded.

Use the `slog-stdlog` create to redirect `log` crate logging calls into
`slog` so they are visible in the agents log output.

Fixes: #978.

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:15:18 +00:00
parent 286eebf087
commit 21cd7ad172
3 changed files with 19 additions and 0 deletions

12
src/agent/Cargo.lock generated
View File

@ -392,6 +392,7 @@ dependencies = [
"signal-hook",
"slog",
"slog-scope",
"slog-stdlog",
"tempfile",
"ttrpc",
]
@ -1077,6 +1078,17 @@ dependencies = [
"slog",
]
[[package]]
name = "slog-stdlog"
version = "4.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8228ab7302adbf4fcb37e66f3cda78003feb521e7fd9e3847ec117a7784d0f5a"
dependencies = [
"log",
"slog",
"slog-scope",
]
[[package]]
name = "smallvec"
version = "1.4.2"

View File

@ -27,6 +27,10 @@ regex = "1"
# (by stopping the compiler from removing log calls).
slog = { version = "2.5.2", features = ["dynamic-keys", "max_level_trace", "release_max_level_info"] }
slog-scope = "4.1.2"
# Redirect ttrpc log calls
slog-stdlog = "4.0.0"
# for testing
tempfile = "3.1.0"
prometheus = { version = "0.9.0", features = ["process"] }

View File

@ -198,6 +198,9 @@ 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()?;
start_sandbox(&logger, &config, init_mode)?;
let _ = log_handle.join();