Skip to content

Commit

Permalink
refactor: suppress info level for fuse backend crate
Browse files Browse the repository at this point in the history
Signed-off-by: BioTheWolff <47079795+BioTheWolff@users.noreply.github.com>
  • Loading branch information
BioTheWolff committed Apr 26, 2024
1 parent 88f5996 commit 69093ed
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 12 deletions.
2 changes: 1 addition & 1 deletion src/fs-gen/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
34 changes: 23 additions & 11 deletions src/fs-gen/src/main.rs
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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) {
Expand All @@ -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())
Expand All @@ -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!(
Expand Down

0 comments on commit 69093ed

Please sign in to comment.