From 69093ed225bc5a8f8cd4582d966ca0b79e5da5eb Mon Sep 17 00:00:00 2001 From: BioTheWolff <47079795+BioTheWolff@users.noreply.github.com> Date: Fri, 26 Apr 2024 12:42:47 +0200 Subject: [PATCH] refactor: suppress info level for fuse backend crate Signed-off-by: BioTheWolff <47079795+BioTheWolff@users.noreply.github.com> --- src/fs-gen/Cargo.toml | 2 +- src/fs-gen/src/main.rs | 34 +++++++++++++++++++++++----------- 2 files changed, 24 insertions(+), 12 deletions(-) diff --git a/src/fs-gen/Cargo.toml b/src/fs-gen/Cargo.toml index a131d9e..eb0b4eb 100644 --- a/src/fs-gen/Cargo.toml +++ b/src/fs-gen/Cargo.toml @@ -20,5 +20,5 @@ tar = "0.4.40" validator = { version = "0.17.0", features = ["derive"] } anyhow = "1.0.82" tracing = "0.1.40" -tracing-subscriber = "0.3.18" +tracing-subscriber = { version = "0.3.18", features = ["env-filter"] } thiserror = "1.0.59" diff --git a/src/fs-gen/src/main.rs b/src/fs-gen/src/main.rs index 4cc2e1d..07ede5f 100644 --- a/src/fs-gen/src/main.rs +++ b/src/fs-gen/src/main.rs @@ -1,8 +1,10 @@ use std::{fs::remove_dir_all, path::Path}; -use tracing::{debug, error, info, Level}; +use tracing::{debug, error, info}; use anyhow::{Result, bail, Context}; -use crate::cli_args::CliArgs; +use tracing::level_filters::LevelFilter; +use tracing_subscriber::filter::EnvFilter; +use crate::cli_args::CliArgs; use crate::initramfs_generator::{create_init_file, generate_initramfs, insert_agent}; use crate::image_builder::merge_layer; use crate::loader::download::download_image_fs; @@ -16,10 +18,9 @@ fn run( args: CliArgs, ) -> Result<()> { let layers_subdir = args.temp_directory.join("layers/"); - let output_subdir = args.temp_directory.join("output/"); let overlay_subdir = args.temp_directory.join("overlay/"); - - let path = Path::new(output_subdir.as_path()); + let _binding = args.temp_directory.join("output/"); + let output_subdir = _binding.as_path(); // image downloading and unpacking let layers_paths = match download_image_fs(&args.image_name, &args.architecture, layers_subdir) { @@ -29,12 +30,12 @@ fn run( debug!("Layers' paths: {:?}", layers_paths); // reconstructing image with overlayfs - merge_layer(&layers_paths, path, &overlay_subdir)?; + merge_layer(&layers_paths, output_subdir, &overlay_subdir)?; // building initramfs - create_init_file(path, args.initfile_path)?; - insert_agent(path, args.agent_host_path)?; - generate_initramfs(path, Path::new(args.output_file.as_path()))?; + create_init_file(output_subdir, args.initfile_path)?; + insert_agent(output_subdir, args.agent_host_path)?; + generate_initramfs(output_subdir, Path::new(args.output_file.as_path()))?; // cleanup of temporary directory remove_dir_all(args.temp_directory.clone()) @@ -47,10 +48,21 @@ fn main() -> Result<()> { let args = CliArgs::get_args(); tracing_subscriber::fmt() - .with_max_level(if args.debug { Level::DEBUG } else { Level::INFO }) + .with_env_filter( + EnvFilter::builder() + .with_default_directive( + (if args.debug { LevelFilter::DEBUG } else { LevelFilter::INFO }).into() + ) + .from_env()? + .add_directive("fuse_backend_rs=warn".parse()?) + ) .init(); + + // tracing_subscriber::fmt() + // .with_max_level(if args.debug { Level::DEBUG } else { Level::INFO }) + // .init(); - info!("Cloudlet initramfs generator v{}", env!("CARGO_PKG_VERSION")); + info!("Cloudlet initramfs generator: '{}' v{}", env!("CARGO_PKG_NAME"), env!("CARGO_PKG_VERSION")); info!("Generating for image '{}'", args.image_name); debug!(