feat(tvix/store): add logging with tracing

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
This commit is contained in:
Florian Klink 2022-12-28 17:17:53 +01:00 committed by flokli
parent 0bf2b0ef11
commit 319c03f634
7 changed files with 327 additions and 10 deletions

View file

@ -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?;