[pbs-devel] [PATCH proxmox-backup 1/2] fix #4578: use log crate for pxar create logging

Fabian Grünbichler f.gruenbichler at proxmox.com
Wed Mar 8 11:57:47 CET 2023


since proxmox-backup-client is used in cron jobs and similar automated
fashions, PBS_LOG= should control the output..

Signed-off-by: Fabian Grünbichler <f.gruenbichler at proxmox.com>
---
came up a few times in the forum already, follow up to the switch to log

 pbs-client/src/pxar/create.rs | 18 +-----------------
 1 file changed, 1 insertion(+), 17 deletions(-)

diff --git a/pbs-client/src/pxar/create.rs b/pbs-client/src/pxar/create.rs
index 1bce3a41..4bc22bf4 100644
--- a/pbs-client/src/pxar/create.rs
+++ b/pbs-client/src/pxar/create.rs
@@ -113,20 +113,6 @@ struct HardLinkInfo {
     st_ino: u64,
 }
 
-/// TODO: make a builder for the create_archive call for fewer parameters and add a method to add a
-/// logger which does not write to stderr.
-struct Logger;
-
-impl std::io::Write for Logger {
-    fn write(&mut self, data: &[u8]) -> io::Result<usize> {
-        std::io::stderr().write(data)
-    }
-
-    fn flush(&mut self) -> io::Result<()> {
-        std::io::stderr().flush()
-    }
-}
-
 /// And the error case.
 struct ErrorReporter;
 
@@ -155,7 +141,6 @@ struct Archiver {
     device_set: Option<HashSet<u64>>,
     hardlinks: HashMap<HardLinkInfo, (PathBuf, LinkOffset)>,
     errors: ErrorReporter,
-    logger: Logger,
     file_copy_buffer: Vec<u8>,
 }
 
@@ -221,7 +206,6 @@ where
         device_set,
         hardlinks: HashMap::new(),
         errors: ErrorReporter,
-        logger: Logger,
         file_copy_buffer: vec::undefined(4 * 1024 * 1024),
     };
 
@@ -706,7 +690,7 @@ impl Archiver {
         }
 
         let result = if skip_contents {
-            writeln!(self.logger, "skipping mount point: {:?}", self.path)?;
+            log::info!("skipping mount point: {:?}", self.path);
             Ok(())
         } else {
             self.archive_dir_contents(&mut encoder, dir, false).await
-- 
2.30.2






More information about the pbs-devel mailing list