summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthias Beyer <matthias.beyer@ifm.com>2022-08-04 20:22:18 +0200
committerMatthias Beyer <matthias.beyer@ifm.com>2022-08-30 13:54:49 +0200
commit26548e7de50ba1c3fc25f1b7d2974b3d83ef2c12 (patch)
tree8c5cf35b7157fb393fba8c92fdf98e20d23f8832
parent08a32f3294d65b4011e54838fc67c792cf8f3ff0 (diff)
WIP: Add tracing-tree backend for tracing outputpost-merge/tracing-tree
-rw-r--r--Cargo.lock14
-rw-r--r--tedge/Cargo.toml1
-rw-r--r--tedge/src/cli.rs6
-rw-r--r--tedge/src/logging.rs14
-rw-r--r--tedge/src/main.rs1
5 files changed, 33 insertions, 3 deletions
diff --git a/Cargo.lock b/Cargo.lock
index 0aa66dcb..17ca49ce 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -3565,6 +3565,7 @@ dependencies = [
"tracing-chrome",
"tracing-subscriber",
"tracing-tracy",
+ "tracing-tree",
]
[[package]]
@@ -4251,6 +4252,19 @@ dependencies = [
]
[[package]]
+name = "tracing-tree"
+version = "0.2.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "d07e90b329c621ade432823988574e820212648aa40e7a2497777d58de0fb453"
+dependencies = [
+ "ansi_term",
+ "atty",
+ "tracing-core",
+ "tracing-log",
+ "tracing-subscriber",
+]
+
+[[package]]
name = "tracy-client"
version = "0.13.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
diff --git a/tedge/Cargo.toml b/tedge/Cargo.toml
index 9e81f7cd..edf7c563 100644
--- a/tedge/Cargo.toml
+++ b/tedge/Cargo.toml
@@ -23,6 +23,7 @@ tracing = "0.1"
tracing-subscriber = { version = "0.3.11", features = ["env-filter"] }
tracing-chrome = "0.6"
tracing-tracy = "0.9"
+tracing-tree = "0.2.1"
cfg_table = "1.0.0"
nu-ansi-term = "0.45.1"
pretty = { version = "0.11.3", features = ["termcolor"] }
diff --git a/tedge/src/cli.rs b/tedge/src/cli.rs
index e01bc313..c58a03c1 100644
--- a/tedge/src/cli.rs
+++ b/tedge/src/cli.rs
@@ -28,6 +28,12 @@ pub struct Cli {
#[clap(long)]
pub tracy_logging: bool,
+ /// Enable tree-style tracing output
+ ///
+ /// If set, "tree-style" tracing output will be produced instead of the default one
+ #[clap(long)]
+ pub tree_logging: bool,
+
#[clap(subcommand)]
pub command: CliCommand,
}
diff --git a/tedge/src/logging.rs b/tedge/src/logging.rs
index a2d60e76..ff4de8f0 100644
--- a/tedge/src/logging.rs
+++ b/tedge/src/logging.rs
@@ -1,3 +1,4 @@
+use std::ops::Not;
use std::path::PathBuf;
use tracing_subscriber::filter::EnvFilter;
@@ -11,6 +12,7 @@ pub fn setup_logging(
spec: Option<LoggingSpec>,
chrome_logging: Option<&PathBuf>,
tracy_logging: bool,
+ tree_logging: bool,
) -> miette::Result<LogGuard> {
let env_filter = match spec {
None => {
@@ -60,13 +62,19 @@ pub fn setup_logging(
.unwrap_or_default();
let opt_tracy_layer = tracy_logging.then(tracing_tracy::TracyLayer::new);
-
- let stdout_log = env_filter.map(|f| tracing_subscriber::fmt::layer().with_filter(f));
+ let opt_tree_layer = {
+ let indent_size = 4;
+ tree_logging.then(|| tracing_tree::HierarchicalLayer::new(indent_size))
+ };
+ let opt_stdout_log = tree_logging
+ .not()
+ .then(|| env_filter.map(|f| tracing_subscriber::fmt::layer().with_filter(f)));
let subscriber = tracing_subscriber::registry::Registry::default()
.with(opt_chrome_layer)
.with(opt_tracy_layer)
- .with(stdout_log);
+ .with(opt_tree_layer)
+ .with(opt_stdout_log);
tracing::subscriber::set_global_default(subscriber)
.map_err(|e| miette::miette!("Failed to set global subscriber: {:?}", e))?;
diff --git a/tedge/src/main.rs b/tedge/src/main.rs
index 18ffc316..776f83be 100644
--- a/tedge/src/main.rs
+++ b/tedge/src/main.rs
@@ -14,6 +14,7 @@ async fn main() -> miette::Result<()> {
args.logging,
args.chrome_logging.as_ref(),
args.tracy_logging,
+ args.tree_logging,
)?;
info!("Tedge booting...");
debug!(?args, "Tedge CLI");