diff options
author | Florian Klink <flokli@flokli.de> | 2022-12-28T16·17+0100 |
---|---|---|
committer | flokli <flokli@flokli.de> | 2022-12-30T20·25+0000 |
commit | 319c03f63413a82d9266ed939eba7f7e552dd2b2 (patch) | |
tree | 7ed69310905fd8f4d7250aca3eb0976119f62a70 /tvix/store/src/main.rs | |
parent | 0bf2b0ef1164aae0ad692066e8cfc0b243a89e4d (diff) |
feat(tvix/store): add logging with tracing r/5558
This uses [tracing](https://github.com/tokio-rs/tracing) for logs/ tracing. Annotate all method handlers with an instrument macro, and warn! a message for them being unimplemented. Co-Authored-By: Márton Boros <martonboros@gmail.com> Change-Id: Id42a41db33782d82abfb8dc0e49a8915000e5d89 Reviewed-on: https://cl.tvl.fyi/c/depot/+/7665 Reviewed-by: tazjin <tazjin@tvl.su> Tested-by: BuildkiteCI
Diffstat (limited to '')
-rw-r--r-- | tvix/store/src/main.rs | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/tvix/store/src/main.rs b/tvix/store/src/main.rs index b28c3fdeefe8..d9261fc34d6e 100644 --- a/tvix/store/src/main.rs +++ b/tvix/store/src/main.rs @@ -7,6 +7,7 @@ use crate::proto::FILE_DESCRIPTOR_SET; use clap::Parser; use tonic::{transport::Server, Result}; +use tracing::{info, Level}; mod dummy_blob_service; mod dummy_directory_service; @@ -23,6 +24,9 @@ mod tests; struct Cli { #[clap(long, short = 'l')] listen_address: Option<String>, + + #[clap(long)] + log_level: Option<Level>, } #[tokio::main] @@ -34,6 +38,10 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> { .parse() .unwrap(); + let level = cli.log_level.unwrap_or(Level::INFO); + let subscriber = tracing_subscriber::fmt().with_max_level(level).finish(); + tracing::subscriber::set_global_default(subscriber).ok(); + let mut server = Server::builder(); let blob_service = dummy_blob_service::DummyBlobService {}; @@ -53,7 +61,7 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> { router = router.add_service(reflection_svc); } - println!("tvix-store listening on {}", listen_address); + info!("tvix-store listening on {}", listen_address); router.serve(listen_address).await?; |