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 C36A8693FE for ; Fri, 11 Mar 2022 16:08:40 +0100 (CET) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id A1340267F7 for ; Fri, 11 Mar 2022 16:08:10 +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 E191F26708 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 AF28C46389 for ; Fri, 11 Mar 2022 16:08:05 +0100 (CET) From: Hannes Laimer To: pbs-devel@lists.proxmox.com Date: Fri, 11 Mar 2022 15:07:54 +0000 Message-Id: <20220311150755.73338-10-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 09/10] 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:40 -0000 Signed-off-by: Hannes Laimer --- examples/upload-speed.rs | 2 +- .../src/proxmox_restore_daemon/api.rs | 1 - pxar-bin/Cargo.toml | 1 + pxar-bin/src/main.rs | 48 ++++--------------- src/api2/admin/datastore.rs | 2 +- src/bin/sg-tape-cmd.rs | 10 ++-- 6 files changed, 16 insertions(+), 48 deletions(-) diff --git a/examples/upload-speed.rs b/examples/upload-speed.rs index 04e35124..d29c25ba 100644 --- a/examples/upload-speed.rs +++ b/examples/upload-speed.rs @@ -21,7 +21,7 @@ async fn upload_speed() -> Result { let client = BackupWriter::start(client, None, datastore, "host", "speedtest", backup_time, false, true).await?; println!("start upload speed test"); - let res = client.upload_speedtest(true).await?; + let res = client.upload_speedtest().await?; Ok(res) } diff --git a/proxmox-restore-daemon/src/proxmox_restore_daemon/api.rs b/proxmox-restore-daemon/src/proxmox_restore_daemon/api.rs index 1333590d..0875e291 100644 --- a/proxmox-restore-daemon/src/proxmox_restore_daemon/api.rs +++ b/proxmox-restore-daemon/src/proxmox_restore_daemon/api.rs @@ -333,7 +333,6 @@ fn extract( entries_max: ENCODER_MAX_ENTRIES, device_set: None, patterns, - verbose: false, skip_lost_and_found: false, }; diff --git a/pxar-bin/Cargo.toml b/pxar-bin/Cargo.toml index 14c447a0..b7f93666 100644 --- a/pxar-bin/Cargo.toml +++ b/pxar-bin/Cargo.toml @@ -11,6 +11,7 @@ path = "src/main.rs" [dependencies] anyhow = "1.0" futures = "0.3" +log = "0.4" nix = "0.19.1" serde_json = "1.0" tokio = { version = "1.6", features = [ "rt", "rt-multi-thread" ] } diff --git a/pxar-bin/src/main.rs b/pxar-bin/src/main.rs index 495cc119..4268eba0 100644 --- a/pxar-bin/src/main.rs +++ b/pxar-bin/src/main.rs @@ -21,7 +21,6 @@ fn extract_archive_from_reader( reader: &mut R, target: &str, feature_flags: Flags, - verbose: bool, options: PxarExtractOptions, ) -> Result<(), Error> { pbs_client::pxar::extract_archive( @@ -29,9 +28,7 @@ fn extract_archive_from_reader( Path::new(target), feature_flags, |path| { - if verbose { - println!("{:?}", path); - } + log::debug!("{:?}", path); }, options, ) @@ -56,11 +53,6 @@ fn extract_archive_from_reader( description: "Target directory", optional: true, }, - verbose: { - description: "Verbose output.", - optional: true, - default: false, - }, "no-xattrs": { description: "Ignore extended file attributes.", optional: true, @@ -114,7 +106,6 @@ fn extract_archive( archive: String, pattern: Option>, target: Option, - verbose: bool, no_xattrs: bool, no_fcaps: bool, no_acls: bool, @@ -178,7 +169,7 @@ fn extract_archive( // otherwise we want to log them but not act on them Some(Box::new(move |err| { was_ok.store(false, Ordering::Release); - eprintln!("error: {}", err); + log::error!("error: {}", err); Ok(()) }) as Box Result<(), Error> + Send>) }; @@ -197,20 +188,16 @@ fn extract_archive( &mut reader, target, feature_flags, - verbose, options, )?; } else { - if verbose { - println!("PXAR extract: {}", archive); - } + log::debug!("PXAR extract: {}", archive); let file = std::fs::File::open(archive)?; let mut reader = std::io::BufReader::new(file); extract_archive_from_reader( &mut reader, target, feature_flags, - verbose, options, )?; } @@ -231,11 +218,6 @@ fn extract_archive( source: { description: "Source directory.", }, - verbose: { - description: "Verbose output.", - optional: true, - default: false, - }, "no-xattrs": { description: "Ignore extended file attributes.", optional: true, @@ -295,7 +277,6 @@ fn extract_archive( async fn create_archive( archive: String, source: String, - verbose: bool, no_xattrs: bool, no_fcaps: bool, no_acls: bool, @@ -328,7 +309,6 @@ async fn create_archive( entries_max: entries_max as usize, device_set, patterns, - verbose, skip_lost_and_found: false, }; @@ -374,9 +354,7 @@ async fn create_archive( writer, feature_flags, move |path| { - if verbose { - println!("{:?}", path); - } + log::debug!("{:?}", path); Ok(()) }, None, @@ -418,9 +396,7 @@ async fn mount_archive( select! { res = session.fuse() => res?, _ = interrupt.recv().fuse() => { - if verbose { - eprintln!("interrupted"); - } + log::debug!("interrupted"); } } @@ -433,24 +409,16 @@ async fn mount_archive( archive: { description: "Archive name.", }, - verbose: { - description: "Verbose output.", - optional: true, - default: false, - }, }, }, )] /// List the contents of an archive. -fn dump_archive(archive: String, verbose: bool) -> Result<(), Error> { +fn dump_archive(archive: String) -> Result<(), Error> { for entry in pxar::decoder::Decoder::open(archive)? { let entry = entry?; - if verbose { - println!("{}", format_single_line_entry(&entry)); - } else { - println!("{:?}", entry.path()); - } + log::debug!("{}", format_single_line_entry(&entry)); + log::info!("{:?}", entry.path()); } Ok(()) } diff --git a/src/api2/admin/datastore.rs b/src/api2/admin/datastore.rs index ef82b426..23d9bb87 100644 --- a/src/api2/admin/datastore.rs +++ b/src/api2/admin/datastore.rs @@ -1522,7 +1522,7 @@ pub fn pxar_file_download( let (sender, receiver) = tokio::sync::mpsc::channel(100); let channelwriter = AsyncChannelWriter::new(sender, 1024 * 1024); proxmox_rest_server::spawn_internal_task( - create_zip(channelwriter, decoder, path.clone(), false) + create_zip(channelwriter, decoder, path.clone()) ); Body::wrap_stream(ReceiverStream::new(receiver).map_err(move |err| { eprintln!("error during streaming of zip '{:?}' - {}", path, err); diff --git a/src/bin/sg-tape-cmd.rs b/src/bin/sg-tape-cmd.rs index 30d022d7..6fa34878 100644 --- a/src/bin/sg-tape-cmd.rs +++ b/src/bin/sg-tape-cmd.rs @@ -35,13 +35,13 @@ fn get_tape_handle(param: &Value) -> Result { let handle = 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); open_lto_tape_drive(&drive)? } else if let Some(device) = param["device"].as_str() { - eprintln!("using device {}", device); + log::info!("using device {}", device); LtoTapeHandle::new(open_lto_tape_device(device)?)? } else if let Some(true) = param["stdin"].as_bool() { - eprintln!("using stdin"); + log::info!("using stdin"); let fd = std::io::stdin().as_raw_fd(); let file = unsafe { File::from_raw_fd(fd) }; check_tape_is_lto_tape_device(&file)?; @@ -49,7 +49,7 @@ fn get_tape_handle(param: &Value) -> Result { } else 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); open_lto_tape_drive(&drive)? } else { let (config, _digest) = pbs_config::drive::config()?; @@ -63,7 +63,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); open_lto_tape_drive(&drive)? } else { bail!("no drive/device specified"); -- 2.30.2