From eb44ed9ac7ca648f18b87b5ed89c7770c7790a3e Mon Sep 17 00:00:00 2001 From: Divma <26765164+divagant-martian@users.noreply.github.com> Date: Fri, 12 Apr 2024 10:44:43 -0500 Subject: [PATCH] feat(iroh-cli): add file logging by default for start commands (#2175) ## Description Adds file logging by default to commands that start a node. Parameters are: - the "RUST_LOG" directive, in the form of and env var `IROH_FILE_RUST_LOG` or in the configuration file. - rotation: how often a new file is created. Either daily, hourly or never. - max files: Maximum number of files to keep File logging can be disabled by either setting the max_files to 0 in the configuration file or by setting the rust log statement to off, in either the env var or the config file. (example config file) ```toml [file_logs] rust_log = "iroh=trace" rotation = "daily" max_files = 1 ``` The files created live the `IROH_DATA_DIR/logs` dir and are named `iroh-2024-03-02.log` (for a daily rotation, or with the hour, for an hourly rotation) By default, we log everything in debug, rotating hourly, keeping at most 4 files (so total 4 hours of logs). This is short default since debug logs, even in an idle node, are a lot ## Notes & open questions n/a ## Change checklist - [x] Self-review. - [x] Documentation updates if relevant. - [ ] Tests if relevant. --------- Co-authored-by: Floris Bruynooghe --- Cargo.lock | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/Cargo.lock b/Cargo.lock index 2e2b0d8018..ffa2ae6e3a 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2420,6 +2420,7 @@ dependencies = [ "regex", "rustyline", "serde", + "serde_with", "shell-words", "shellexpand", "strum 0.26.2", @@ -2429,6 +2430,7 @@ dependencies = [ "time", "tokio", "tracing", + "tracing-appender", "tracing-subscriber", "walkdir", ] @@ -5333,6 +5335,18 @@ dependencies = [ "tracing-core", ] +[[package]] +name = "tracing-appender" +version = "0.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3566e8ce28cc0a3fe42519fc80e6b4c943cc4c8cef275620eb8dac2d3d4e06cf" +dependencies = [ + "crossbeam-channel", + "thiserror", + "time", + "tracing-subscriber", +] + [[package]] name = "tracing-attributes" version = "0.1.27"