diff options
author | Simon Hauser <simon.hauser@helsinki-systems.de> | 2024-06-06T13·44+0200 |
---|---|---|
committer | clbot <clbot@tvl.fyi> | 2024-06-10T16·35+0000 |
commit | 825d498908e2f6c9fdca3225afefb0aa4b3cc747 (patch) | |
tree | 765e5412bf24ae41bb3d6f42791a229b68a88451 /tvix/build | |
parent | 11a6ff77067a7b9eec3f1c15412d7143cb85a047 (diff) |
feat(tvix/tracing): introduce common tvix-tracing crate r/8242
Introduce a new common crate that contains tracing boilerplate which then can be used in the cli, tvix-store and tvix-build crates. It has otlp as an optional feature, which is currently only used by tvix-store. Change-Id: I41468ac4d9c65174515d721513b96fea463d6ed2 Reviewed-on: https://cl.tvl.fyi/c/depot/+/11758 Tested-by: BuildkiteCI Reviewed-by: flokli <flokli@flokli.de> Autosubmit: Simon Hauser <simon.hauser@helsinki-systems.de>
Diffstat (limited to 'tvix/build')
-rw-r--r-- | tvix/build/Cargo.toml | 4 | ||||
-rw-r--r-- | tvix/build/src/bin/tvix-build.rs | 20 |
2 files changed, 9 insertions, 15 deletions
diff --git a/tvix/build/Cargo.toml b/tvix/build/Cargo.toml index c8123c2617f6..6faa3ad7abdb 100644 --- a/tvix/build/Cargo.toml +++ b/tvix/build/Cargo.toml @@ -13,8 +13,8 @@ tokio = { version = "1.32.0" } tokio-listener = { version = "0.4.1", features = [ "tonic011" ] } tonic = { version = "0.11.0", features = ["tls", "tls-roots"] } tvix-castore = { path = "../castore" } -tracing = "0.1.37" -tracing-subscriber = "0.3.16" +tvix-tracing = { path = "../tracing" } +tracing = "0.1.40" url = "2.4.0" [dependencies.tonic-reflection] diff --git a/tvix/build/src/bin/tvix-build.rs b/tvix/build/src/bin/tvix-build.rs index 07d7e30dfda5..07085a433cfa 100644 --- a/tvix/build/src/bin/tvix-build.rs +++ b/tvix/build/src/bin/tvix-build.rs @@ -7,7 +7,6 @@ use tokio_listener::SystemOptions; use tokio_listener::UserOptions; use tonic::{self, transport::Server}; use tracing::{info, Level}; -use tracing_subscriber::prelude::*; use tvix_build::{ buildservice, proto::{build_service_server::BuildServiceServer, GRPCBuildServiceWrapper}, @@ -23,8 +22,12 @@ use tvix_castore::proto::FILE_DESCRIPTOR_SET as CASTORE_FILE_DESCRIPTOR_SET; #[derive(Parser)] #[command(author, version, about, long_about = None)] struct Cli { - #[arg(long)] - log_level: Option<Level>, + /// A global log level to use when printing logs. + /// It's also possible to set `RUST_LOG` according to + /// `tracing_subscriber::filter::EnvFilter`, which will always have + /// priority. + #[arg(long, default_value_t=Level::INFO)] + log_level: Level, #[command(subcommand)] command: Commands, @@ -51,16 +54,7 @@ enum Commands { async fn main() -> Result<(), Box<dyn std::error::Error>> { let cli = Cli::parse(); - // configure log settings - let level = cli.log_level.unwrap_or(Level::INFO); - - tracing_subscriber::registry() - .with( - tracing_subscriber::fmt::Layer::new() - .with_writer(std::io::stderr.with_max_level(level)) - .pretty(), - ) - .init(); + tvix_tracing::init(cli.log_level)?; match cli.command { Commands::Daemon { |