From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from firstgate.proxmox.com (firstgate.proxmox.com [212.224.123.68]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by lists.proxmox.com (Postfix) with ESMTPS id 5EBEC69393 for ; Fri, 11 Mar 2022 16:08:10 +0100 (CET) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 943BD267A8 for ; Fri, 11 Mar 2022 16:08:09 +0100 (CET) Received: from proxmox-new.maurer-it.com (proxmox-new.maurer-it.com [94.136.29.106]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by firstgate.proxmox.com (Proxmox) with ESMTPS id 1C557266F7 for ; Fri, 11 Mar 2022 16:08:05 +0100 (CET) Received: from proxmox-new.maurer-it.com (localhost.localdomain [127.0.0.1]) by proxmox-new.maurer-it.com (Proxmox) with ESMTP id E6DDB463BD for ; Fri, 11 Mar 2022 16:08:04 +0100 (CET) From: Hannes Laimer To: pbs-devel@lists.proxmox.com Date: Fri, 11 Mar 2022 15:07:50 +0000 Message-Id: <20220311150755.73338-6-h.laimer@proxmox.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220311150755.73338-1-h.laimer@proxmox.com> References: <20220311150755.73338-1-h.laimer@proxmox.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SPAM-LEVEL: Spam detection results: 0 AWL 0.040 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record T_SCC_BODY_TEXT_LINE -0.01 - Subject: [pbs-devel] [PATCH proxmox-backup 05/10] pbs-fuse+pbs-tape: replace print with log macro X-BeenThere: pbs-devel@lists.proxmox.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Proxmox Backup Server development discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 11 Mar 2022 15:08:10 -0000 Signed-off-by: Hannes Laimer --- pbs-fuse-loop/Cargo.toml | 1 + pbs-fuse-loop/src/fuse_loop.rs | 12 ++++++------ pbs-tape/Cargo.toml | 1 + pbs-tape/src/bin/pmt.rs | 10 +++++----- pbs-tape/src/bin/pmtx.rs | 8 ++++---- pbs-tape/src/sg_pt_changer.rs | 4 ++-- 6 files changed, 19 insertions(+), 17 deletions(-) diff --git a/pbs-fuse-loop/Cargo.toml b/pbs-fuse-loop/Cargo.toml index b6ed46da..ff90dd8c 100644 --- a/pbs-fuse-loop/Cargo.toml +++ b/pbs-fuse-loop/Cargo.toml @@ -10,6 +10,7 @@ anyhow = "1.0" futures = "0.3" lazy_static = "1.4" libc = "0.2" +log = "0.4" nix = "0.19.1" regex = "1.5" tokio = { version = "1.6", features = [] } diff --git a/pbs-fuse-loop/src/fuse_loop.rs b/pbs-fuse-loop/src/fuse_loop.rs index a763c308..dd9bc1ff 100644 --- a/pbs-fuse-loop/src/fuse_loop.rs +++ b/pbs-fuse-loop/src/fuse_loop.rs @@ -141,7 +141,7 @@ impl FuseLoopSession { let cleanup = |session: futures::stream::Fuse| { // only warn for errors on cleanup, if these fail nothing is lost if let Err(err) = loopdev::unassign(&loopdev_path) { - eprintln!( + log::warn!( "cleanup: warning: could not unassign file {} from loop device {} - {}", &fuse_path, &loopdev_path, err, ); @@ -151,13 +151,13 @@ impl FuseLoopSession { std::mem::drop(session); if let Err(err) = remove_file(&fuse_path) { - eprintln!( + log::warn!( "cleanup: warning: could not remove temporary file {} - {}", &fuse_path, err, ); } if let Err(err) = remove_file(&pid_path) { - eprintln!( + log::warn!( "cleanup: warning: could not remove PID file {} - {}", &pid_path, err, ); @@ -200,7 +200,7 @@ impl FuseLoopSession { }, Some(_) => { // only FUSE requests necessary for loop-mapping are implemented - eprintln!("Unimplemented FUSE request type encountered"); + log::error!("Unimplemented FUSE request type encountered"); Ok(()) }, None => { @@ -239,7 +239,7 @@ pub fn cleanup_unused_run_files(filter_name: Option) { // does nothing if files are already stagnant (e.g. instance crashed etc...) if unmap_from_backing(&path, None).is_ok() { // we have reaped some leftover instance, tell the user - eprintln!( + log::info!( "Cleaned up dangling mapping '{}': no loop device assigned", &name ); @@ -291,7 +291,7 @@ fn get_backing_file(loopdev: &str) -> Result { // call in broken state: we found the mapping, but the client is already dead, // only thing to do is clean up what we can fn emerg_cleanup(loopdev: Option<&str>, mut backing_file: PathBuf) { - eprintln!( + log::warn!( "warning: found mapping with dead process ({:?}), attempting cleanup", &backing_file ); diff --git a/pbs-tape/Cargo.toml b/pbs-tape/Cargo.toml index a2edbdde..d79d5209 100644 --- a/pbs-tape/Cargo.toml +++ b/pbs-tape/Cargo.toml @@ -8,6 +8,7 @@ description = "LTO tage support" [dependencies] lazy_static = "1.4" libc = "0.2" +log = "0.4" anyhow = "1.0" thiserror = "1.0" endian_trait = { version = "0.6", features = ["arrays"] } diff --git a/pbs-tape/src/bin/pmt.rs b/pbs-tape/src/bin/pmt.rs index a5b9271d..934fa56f 100644 --- a/pbs-tape/src/bin/pmt.rs +++ b/pbs-tape/src/bin/pmt.rs @@ -63,24 +63,24 @@ fn get_tape_handle(param: &Value) -> Result { if let Some(name) = param["drive"].as_str() { let (config, _digest) = pbs_config::drive::config()?; let drive: LtoTapeDrive = config.lookup("lto", name)?; - eprintln!("using device {}", drive.path); + log::info!("using device {}", drive.path); return SgTape::new(open_lto_tape_device(&drive.path)?); } if let Some(device) = param["device"].as_str() { - eprintln!("using device {}", device); + log::info!("using device {}", device); return SgTape::new(open_lto_tape_device(device)?); } if let Ok(name) = std::env::var("PROXMOX_TAPE_DRIVE") { let (config, _digest) = pbs_config::drive::config()?; let drive: LtoTapeDrive = config.lookup("lto", &name)?; - eprintln!("using device {}", drive.path); + log::info!("using device {}", drive.path); return SgTape::new(open_lto_tape_device(&drive.path)?); } if let Ok(device) = std::env::var("TAPE") { - eprintln!("using device {}", device); + log::info!("using device {}", device); return SgTape::new(open_lto_tape_device(&device)?); } @@ -95,7 +95,7 @@ fn get_tape_handle(param: &Value) -> Result { if drive_names.len() == 1 { let name = drive_names[0]; let drive: LtoTapeDrive = config.lookup("lto", name)?; - eprintln!("using device {}", drive.path); + log::info!("using device {}", drive.path); return SgTape::new(open_lto_tape_device(&drive.path)?); } diff --git a/pbs-tape/src/bin/pmtx.rs b/pbs-tape/src/bin/pmtx.rs index 604d7ce2..c4ed3951 100644 --- a/pbs-tape/src/bin/pmtx.rs +++ b/pbs-tape/src/bin/pmtx.rs @@ -37,12 +37,12 @@ fn get_changer_handle(param: &Value) -> Result { if let Some(name) = param["changer"].as_str() { let (config, _digest) = pbs_config::drive::config()?; let changer_config: ScsiTapeChanger = config.lookup("changer", name)?; - eprintln!("using device {}", changer_config.path); + log::info!("using device {}", changer_config.path); return sg_pt_changer::open(&changer_config.path); } if let Some(device) = param["device"].as_str() { - eprintln!("using device {}", device); + log::info!("using device {}", device); return sg_pt_changer::open(device); } @@ -51,13 +51,13 @@ fn get_changer_handle(param: &Value) -> Result { let drive: LtoTapeDrive = config.lookup("lto", &name)?; if let Some(changer) = drive.changer { let changer_config: ScsiTapeChanger = config.lookup("changer", &changer)?; - eprintln!("using device {}", changer_config.path); + log::info!("using device {}", changer_config.path); return sg_pt_changer::open(&changer_config.path); } } if let Ok(device) = std::env::var("CHANGER") { - eprintln!("using device {}", device); + log::info!("using device {}", device); return sg_pt_changer::open(device); } diff --git a/pbs-tape/src/sg_pt_changer.rs b/pbs-tape/src/sg_pt_changer.rs index d0f9c367..727bed0c 100644 --- a/pbs-tape/src/sg_pt_changer.rs +++ b/pbs-tape/src/sg_pt_changer.rs @@ -93,11 +93,11 @@ fn execute_scsi_command( let msg = err.to_string(); if let Some(ref last) = last_msg { if &msg != last { - eprintln!("{}", err); + log::error!("{}", err); last_msg = Some(msg); } } else { - eprintln!("{}", err); + log::error!("{}", err); last_msg = Some(msg); } -- 2.30.2