From 21cd7ad17249aaca0eabb20f9a77964b89cd5c66 Mon Sep 17 00:00:00 2001 From: "James O. D. Hunt" Date: Tue, 27 Oct 2020 11:15:18 +0000 Subject: [PATCH] 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 --- src/agent/Cargo.lock | 12 ++++++++++++ src/agent/Cargo.toml | 4 ++++ src/agent/src/main.rs | 3 +++ 3 files changed, 19 insertions(+) diff --git a/src/agent/Cargo.lock b/src/agent/Cargo.lock index c2c16f388..b99febaa6 100644 --- a/src/agent/Cargo.lock +++ b/src/agent/Cargo.lock @@ -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" diff --git a/src/agent/Cargo.toml b/src/agent/Cargo.toml index 3013b2d10..28d19c04b 100644 --- a/src/agent/Cargo.toml +++ b/src/agent/Cargo.toml @@ -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"] } diff --git a/src/agent/src/main.rs b/src/agent/src/main.rs index 7ec1f7678..92d87374f 100644 --- a/src/agent/src/main.rs +++ b/src/agent/src/main.rs @@ -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();