feat(logging): centralize logging setup in teepot crate

- Added a new logging module in `teepot` crate.
- Removed redundant logging setup code from individual projects.
- Updated dependencies and references for logging setup.

Signed-off-by: Harald Hoyer <harald@matterlabs.dev>
This commit is contained in:
Harald Hoyer 2024-09-18 13:21:12 +02:00
parent 2ff3b1168d
commit af3ab51320
Signed by: harald
GPG key ID: F519A1143B3FBE32
7 changed files with 85 additions and 68 deletions

View file

@ -15,12 +15,11 @@ use teepot::json::http::{
SignRequest, SignRequestData, SignResponse, VaultCommandRequest, VaultCommands,
VaultCommandsResponse, DIGEST_URL,
};
use teepot::log::{setup_logging, LogLevelParser};
use teepot::server::signatures::verify_sig;
use teepot::sgx::sign::Signature;
use tracing::level_filters::LevelFilter;
use tracing::{error, info};
use tracing_log::LogTracer;
use tracing_subscriber::Registry;
use tracing_subscriber::{fmt, prelude::*, EnvFilter};
#[derive(Args, Debug)]
struct SendArgs {
@ -101,18 +100,18 @@ enum SubCommands {
struct Arguments {
#[clap(subcommand)]
cmd: SubCommands,
/// Log level for the log output.
/// Valid values are: `off`, `error`, `warn`, `info`, `debug`, `trace`
#[clap(long, default_value_t = LevelFilter::WARN, value_parser = LogLevelParser)]
pub log_level: LevelFilter,
}
#[actix_web::main]
async fn main() -> Result<()> {
LogTracer::init().context("Failed to set logger")?;
let subscriber = Registry::default()
.with(EnvFilter::from_default_env())
.with(fmt::layer().with_writer(std::io::stderr));
tracing::subscriber::set_global_default(subscriber).unwrap();
let args = Arguments::parse();
setup_logging(&args.log_level)?;
info!("Quote verified! Connection secure!");
match args.cmd {