all lists on lists.proxmox.com
 help / color / mirror / Atom feed
From: Hannes Laimer <h.laimer@proxmox.com>
To: pbs-devel@lists.proxmox.com
Subject: [pbs-devel] [PATCH proxmox-backup v3 04/10] pbs-fuse+pbs-tape: replace print with log macro
Date: Wed, 15 Jun 2022 08:19:51 +0000	[thread overview]
Message-ID: <20220615081957.33511-6-h.laimer@proxmox.com> (raw)
In-Reply-To: <20220615081957.33511-1-h.laimer@proxmox.com>

Signed-off-by: Hannes Laimer <h.laimer@proxmox.com>
---
 pbs-fuse-loop/Cargo.toml       |  3 ++-
 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, 20 insertions(+), 18 deletions(-)

diff --git a/pbs-fuse-loop/Cargo.toml b/pbs-fuse-loop/Cargo.toml
index cc608848..c9b260e5 100644
--- a/pbs-fuse-loop/Cargo.toml
+++ b/pbs-fuse-loop/Cargo.toml
@@ -11,9 +11,10 @@ futures = "0.3"
 lazy_static = "1.4"
 libc = "0.2"
 nix = "0.24"
+log = "0.4"
 regex = "1.5"
 tokio = { version = "1.6", features = [] }
 
 proxmox-time = "1"
 proxmox-fuse = "0.1.3"
-proxmox-sys = "0.3"
\ No newline at end of file
+proxmox-sys = "0.3"
diff --git a/pbs-fuse-loop/src/fuse_loop.rs b/pbs-fuse-loop/src/fuse_loop.rs
index c92a5390..8660f264 100644
--- a/pbs-fuse-loop/src/fuse_loop.rs
+++ b/pbs-fuse-loop/src/fuse_loop.rs
@@ -141,7 +141,7 @@ impl<R: AsyncRead + AsyncSeek + Unpin> FuseLoopSession<R> {
         let cleanup = |session: futures::stream::Fuse<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<R: AsyncRead + AsyncSeek + Unpin> FuseLoopSession<R> {
             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<R: AsyncRead + AsyncSeek + Unpin> FuseLoopSession<R> {
                         },
                         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<String>) {
                 // 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<String, Error> {
 // 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 dfe65778..1ad80c18 100644
--- a/pbs-tape/Cargo.toml
+++ b/pbs-tape/Cargo.toml
@@ -8,6 +8,7 @@ description = "LTO tape 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 75e8e93a..adf95db2 100644
--- a/pbs-tape/src/bin/pmt.rs
+++ b/pbs-tape/src/bin/pmt.rs
@@ -55,24 +55,24 @@ fn get_tape_handle(param: &Value) -> Result<SgTape, Error> {
     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)?);
     }
 
@@ -89,7 +89,7 @@ fn get_tape_handle(param: &Value) -> Result<SgTape, Error> {
     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 1d58d737..6f34bc44 100644
--- a/pbs-tape/src/bin/pmtx.rs
+++ b/pbs-tape/src/bin/pmtx.rs
@@ -33,12 +33,12 @@ fn get_changer_handle(param: &Value) -> Result<File, Error> {
     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);
     }
 
@@ -47,13 +47,13 @@ fn get_changer_handle(param: &Value) -> Result<File, Error> {
         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 eb581d6c..d413c1e0 100644
--- a/pbs-tape/src/sg_pt_changer.rs
+++ b/pbs-tape/src/sg_pt_changer.rs
@@ -86,11 +86,11 @@ fn execute_scsi_command<F: AsRawFd>(
                 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





  parent reply	other threads:[~2022-06-15  8:20 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-06-15  8:19 [pbs-devel] [PATCH-SERIES proxmox-backup/proxmox v3 00/10] replace print by log macro in libraries Hannes Laimer
2022-06-15  8:19 ` [pbs-devel] [PATCH proxmox v3 1/1] router: add init_cli_logger helper function Hannes Laimer
2022-06-21  8:40   ` [pbs-devel] applied: " Wolfgang Bumiller
2022-06-15  8:19 ` [pbs-devel] [PATCH proxmox-backup v3 01/10] bins: init cli logger Hannes Laimer
2022-06-15  8:19 ` [pbs-devel] [PATCH proxmox-backup v3 02/10] pbs-client: replace print with log macro Hannes Laimer
2022-06-15  8:19 ` [pbs-devel] [PATCH proxmox-backup v3 03/10] pbs-datastore: " Hannes Laimer
2022-06-15  8:19 ` Hannes Laimer [this message]
2022-06-15  8:19 ` [pbs-devel] [PATCH proxmox-backup v3 05/10] proxmox-backup-client: " Hannes Laimer
2022-06-15  8:19 ` [pbs-devel] [PATCH proxmox-backup v3 06/10] proxmox-file-restore: " Hannes Laimer
2022-06-15  8:19 ` [pbs-devel] [PATCH proxmox-backup v3 07/10] proxmox-rest-server: " Hannes Laimer
2022-06-15  8:19 ` [pbs-devel] [PATCH proxmox-backup v3 08/10] " Hannes Laimer
2022-06-15  8:19 ` [pbs-devel] [PATCH proxmox-backup v3 09/10] docs: add note for setting verbosity level Hannes Laimer
2022-06-15  8:19 ` [pbs-devel] [PATCH proxmox-backup v3 10/10] fixed_index: remove unused 'print_info' function Hannes Laimer
2022-06-21  8:46 ` [pbs-devel] applied-series: [PATCH-SERIES proxmox-backup/proxmox v3 00/10] replace print by log macro in libraries Wolfgang Bumiller

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220615081957.33511-6-h.laimer@proxmox.com \
    --to=h.laimer@proxmox.com \
    --cc=pbs-devel@lists.proxmox.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal