fix #4578: use log crate for pxar create logging

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>
This commit is contained in:
Fabian Grünbichler 2023-03-08 11:57:47 +01:00 committed by Wolfgang Bumiller
parent 6b815bc022
commit 8419f1cfca

View File

@ -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