* [pbs-devel] [PATCH proxmox-backup 1/2] fix #4578: use log crate for pxar create logging
@ 2023-03-08 10:57 Fabian Grünbichler
2023-03-08 10:57 ` [pbs-devel] [PATCH proxmox-backup 2/2] pxar creation: use log crate for error reporting Fabian Grünbichler
2023-03-27 9:35 ` [pbs-devel] applied-series: [PATCH proxmox-backup 1/2] fix #4578: use log crate for pxar create logging Wolfgang Bumiller
0 siblings, 2 replies; 3+ messages in thread
From: Fabian Grünbichler @ 2023-03-08 10:57 UTC (permalink / raw)
To: pbs-devel
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@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
^ permalink raw reply [flat|nested] 3+ messages in thread
* [pbs-devel] [PATCH proxmox-backup 2/2] pxar creation: use log crate for error reporting
2023-03-08 10:57 [pbs-devel] [PATCH proxmox-backup 1/2] fix #4578: use log crate for pxar create logging Fabian Grünbichler
@ 2023-03-08 10:57 ` Fabian Grünbichler
2023-03-27 9:35 ` [pbs-devel] applied-series: [PATCH proxmox-backup 1/2] fix #4578: use log crate for pxar create logging Wolfgang Bumiller
1 sibling, 0 replies; 3+ messages in thread
From: Fabian Grünbichler @ 2023-03-08 10:57 UTC (permalink / raw)
To: pbs-devel
gives a higher (runtime) control via PBS_LOG, so that users can decide
themselves which messages, sources and levels are interesting for a particular
use case.
Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
---
Notes:
could also be seen as part of fixing #4578 and squashed into previous commit
tried to follow a basic "can happen, but might be noteworthy" vs "should be
fixed" when deciding on warn vs. error.
pbs-client/src/pxar/create.rs | 47 ++++++++---------------------------
1 file changed, 11 insertions(+), 36 deletions(-)
diff --git a/pbs-client/src/pxar/create.rs b/pbs-client/src/pxar/create.rs
index 4bc22bf4..613559d2 100644
--- a/pbs-client/src/pxar/create.rs
+++ b/pbs-client/src/pxar/create.rs
@@ -1,7 +1,7 @@
use std::collections::{HashMap, HashSet};
use std::ffi::{CStr, CString, OsStr};
use std::fmt;
-use std::io::{self, Read, Write};
+use std::io::{self, Read};
use std::os::unix::ffi::OsStrExt;
use std::os::unix::io::{AsRawFd, FromRawFd, IntoRawFd, OwnedFd, RawFd};
use std::path::{Path, PathBuf};
@@ -113,19 +113,6 @@ struct HardLinkInfo {
st_ino: u64,
}
-/// And the error case.
-struct ErrorReporter;
-
-impl std::io::Write for ErrorReporter {
- fn write(&mut self, data: &[u8]) -> io::Result<usize> {
- std::io::stderr().write(data)
- }
-
- fn flush(&mut self) -> io::Result<()> {
- std::io::stderr().flush()
- }
-}
-
struct Archiver {
feature_flags: Flags,
fs_feature_flags: Flags,
@@ -140,7 +127,6 @@ struct Archiver {
current_st_dev: libc::dev_t,
device_set: Option<HashSet<u64>>,
hardlinks: HashMap<HardLinkInfo, (PathBuf, LinkOffset)>,
- errors: ErrorReporter,
file_copy_buffer: Vec<u8>,
}
@@ -205,7 +191,6 @@ where
current_st_dev: stat.st_dev,
device_set,
hardlinks: HashMap::new(),
- errors: ErrorReporter,
file_copy_buffer: vec::undefined(4 * 1024 * 1024),
};
@@ -317,11 +302,7 @@ impl Archiver {
Ok(None)
}
Err(Errno::EACCES) => {
- writeln!(
- self.errors,
- "failed to open file: {:?}: access denied",
- file_name
- )?;
+ log::warn!("failed to open file: {:?}: access denied", file_name);
Ok(None)
}
Err(Errno::EPERM) if !noatime.is_empty() => {
@@ -351,10 +332,10 @@ impl Archiver {
let line = match line {
Ok(line) => line,
Err(err) => {
- let _ = writeln!(
- self.errors,
+ log::warn!(
"ignoring .pxarexclude after read error in {:?}: {}",
- self.path, err,
+ self.path,
+ err,
);
self.patterns.truncate(old_pattern_count);
return Ok(());
@@ -394,7 +375,7 @@ impl Archiver {
}
}
Err(err) => {
- let _ = writeln!(self.errors, "bad pattern in {:?}: {}", self.path, err);
+ log::error!("bad pattern in {:?}: {}", self.path, err);
}
}
}
@@ -493,29 +474,23 @@ impl Archiver {
}
fn report_vanished_file(&mut self) -> Result<(), Error> {
- writeln!(
- self.errors,
- "warning: file vanished while reading: {:?}",
- self.path
- )?;
+ log::warn!("warning: file vanished while reading: {:?}", self.path);
Ok(())
}
fn report_file_shrunk_while_reading(&mut self) -> Result<(), Error> {
- writeln!(
- self.errors,
+ log::warn!(
"warning: file size shrunk while reading: {:?}, file will be padded with zeros!",
self.path,
- )?;
+ );
Ok(())
}
fn report_file_grew_while_reading(&mut self) -> Result<(), Error> {
- writeln!(
- self.errors,
+ log::warn!(
"warning: file size increased while reading: {:?}, file will be truncated!",
self.path,
- )?;
+ );
Ok(())
}
--
2.30.2
^ permalink raw reply [flat|nested] 3+ messages in thread
* [pbs-devel] applied-series: [PATCH proxmox-backup 1/2] fix #4578: use log crate for pxar create logging
2023-03-08 10:57 [pbs-devel] [PATCH proxmox-backup 1/2] fix #4578: use log crate for pxar create logging Fabian Grünbichler
2023-03-08 10:57 ` [pbs-devel] [PATCH proxmox-backup 2/2] pxar creation: use log crate for error reporting Fabian Grünbichler
@ 2023-03-27 9:35 ` Wolfgang Bumiller
1 sibling, 0 replies; 3+ messages in thread
From: Wolfgang Bumiller @ 2023-03-27 9:35 UTC (permalink / raw)
To: Fabian Grünbichler; +Cc: pbs-devel
applied both patches, thanks
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2023-03-27 9:35 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-03-08 10:57 [pbs-devel] [PATCH proxmox-backup 1/2] fix #4578: use log crate for pxar create logging Fabian Grünbichler
2023-03-08 10:57 ` [pbs-devel] [PATCH proxmox-backup 2/2] pxar creation: use log crate for error reporting Fabian Grünbichler
2023-03-27 9:35 ` [pbs-devel] applied-series: [PATCH proxmox-backup 1/2] fix #4578: use log crate for pxar create logging Wolfgang Bumiller
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.