mirror of
git://git.proxmox.com/git/proxmox-backup.git
synced 2025-02-01 05:47:22 +03:00
pxar-bin: remove log
dependency, use tracing
directly
When using the `log` to `tracing` translation layer, the messages get padded with whitespaces. This bug will get fixed upstream [0], but in the meantime we switch to the `tracing` macros. [0]: https://github.com/tokio-rs/tracing/pull/3070 Tested-by: Christian Ebner <c.ebner@proxmox.com> Reviewed-by: Christian Ebner <c.ebner@proxmox.com> Signed-off-by: Gabriel Goller <g.goller@proxmox.com>
This commit is contained in:
parent
e97132bb64
commit
1de4974eeb
@ -11,7 +11,6 @@ path = "src/main.rs"
|
|||||||
[dependencies]
|
[dependencies]
|
||||||
anyhow.workspace = true
|
anyhow.workspace = true
|
||||||
futures.workspace = true
|
futures.workspace = true
|
||||||
log.workspace = true
|
|
||||||
nix.workspace = true
|
nix.workspace = true
|
||||||
serde_json.workspace = true
|
serde_json.workspace = true
|
||||||
tokio = { workspace = true, features = [ "rt", "rt-multi-thread" ] }
|
tokio = { workspace = true, features = [ "rt", "rt-multi-thread" ] }
|
||||||
|
@ -19,7 +19,7 @@ use pbs_client::pxar::{
|
|||||||
use pxar::EntryKind;
|
use pxar::EntryKind;
|
||||||
|
|
||||||
use proxmox_human_byte::HumanByte;
|
use proxmox_human_byte::HumanByte;
|
||||||
use proxmox_log::init_cli_logger;
|
use proxmox_log::{debug, enabled, error, info, init_cli_logger, Level};
|
||||||
use proxmox_router::cli::*;
|
use proxmox_router::cli::*;
|
||||||
use proxmox_schema::api;
|
use proxmox_schema::api;
|
||||||
|
|
||||||
@ -40,7 +40,7 @@ fn extract_archive_from_reader<R: std::io::Read>(
|
|||||||
Path::new(target),
|
Path::new(target),
|
||||||
feature_flags,
|
feature_flags,
|
||||||
|path| {
|
|path| {
|
||||||
log::debug!("{:?}", path);
|
debug!("{path:?}");
|
||||||
},
|
},
|
||||||
options,
|
options,
|
||||||
)
|
)
|
||||||
@ -222,7 +222,7 @@ fn extract_archive(
|
|||||||
// otherwise we want to log them but not act on them
|
// otherwise we want to log them but not act on them
|
||||||
Some(Box::new(move |err| {
|
Some(Box::new(move |err| {
|
||||||
was_ok.store(false, Ordering::Release);
|
was_ok.store(false, Ordering::Release);
|
||||||
log::error!("error: {}", err);
|
error!("error: {err:?}");
|
||||||
Ok(())
|
Ok(())
|
||||||
})
|
})
|
||||||
as Box<dyn FnMut(Error) -> Result<(), Error> + Send>)
|
as Box<dyn FnMut(Error) -> Result<(), Error> + Send>)
|
||||||
@ -243,7 +243,7 @@ fn extract_archive(
|
|||||||
extract_archive_from_reader(&mut reader, target, feature_flags, options, None)
|
extract_archive_from_reader(&mut reader, target, feature_flags, options, None)
|
||||||
.map_err(|err| format_err!("error extracting archive - {err:#}"))?;
|
.map_err(|err| format_err!("error extracting archive - {err:#}"))?;
|
||||||
} else {
|
} else {
|
||||||
log::debug!("PXAR extract: {}", archive);
|
debug!("PXAR extract: {archive}");
|
||||||
let file = std::fs::File::open(archive)?;
|
let file = std::fs::File::open(archive)?;
|
||||||
let mut reader = std::io::BufReader::new(file);
|
let mut reader = std::io::BufReader::new(file);
|
||||||
let mut payload_reader = if let Some(payload_input) = payload_input {
|
let mut payload_reader = if let Some(payload_input) = payload_input {
|
||||||
@ -439,7 +439,7 @@ async fn create_archive(
|
|||||||
PxarWriters::new(writer, None),
|
PxarWriters::new(writer, None),
|
||||||
feature_flags,
|
feature_flags,
|
||||||
move |path| {
|
move |path| {
|
||||||
log::debug!("{:?}", path);
|
debug!("{path:?}");
|
||||||
Ok(())
|
Ok(())
|
||||||
},
|
},
|
||||||
options,
|
options,
|
||||||
@ -495,7 +495,7 @@ async fn mount_archive(
|
|||||||
select! {
|
select! {
|
||||||
res = session.fuse() => res?,
|
res = session.fuse() => res?,
|
||||||
_ = interrupt.recv().fuse() => {
|
_ = interrupt.recv().fuse() => {
|
||||||
log::debug!("interrupted");
|
debug!("interrupted");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -531,14 +531,14 @@ fn dump_archive(archive: String, payload_input: Option<String>) -> Result<(), Er
|
|||||||
for entry in pxar::decoder::Decoder::open(input)? {
|
for entry in pxar::decoder::Decoder::open(input)? {
|
||||||
let entry = entry?;
|
let entry = entry?;
|
||||||
|
|
||||||
if log::log_enabled!(log::Level::Debug) {
|
if enabled!(Level::DEBUG) {
|
||||||
match entry.kind() {
|
match entry.kind() {
|
||||||
EntryKind::Version(version) => {
|
EntryKind::Version(version) => {
|
||||||
log::debug!("pxar format version '{version:?}'");
|
debug!("pxar format version '{version:?}'");
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
EntryKind::Prelude(prelude) => {
|
EntryKind::Prelude(prelude) => {
|
||||||
log::debug!("prelude of size {}", HumanByte::from(prelude.data.len()));
|
debug!("prelude of size {}", HumanByte::from(prelude.data.len()));
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
EntryKind::File {
|
EntryKind::File {
|
||||||
@ -549,7 +549,7 @@ fn dump_archive(archive: String, payload_input: Option<String>) -> Result<(), Er
|
|||||||
if let Some(last) = last {
|
if let Some(last) = last {
|
||||||
let skipped = offset - last;
|
let skipped = offset - last;
|
||||||
if skipped > 0 {
|
if skipped > 0 {
|
||||||
log::debug!("Encountered padding of {skipped} bytes");
|
debug!("Encountered padding of {skipped} bytes");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
last = Some(offset + size + std::mem::size_of::<pxar::format::Header>() as u64);
|
last = Some(offset + size + std::mem::size_of::<pxar::format::Header>() as u64);
|
||||||
@ -557,11 +557,11 @@ fn dump_archive(archive: String, payload_input: Option<String>) -> Result<(), Er
|
|||||||
_ => (),
|
_ => (),
|
||||||
}
|
}
|
||||||
|
|
||||||
log::debug!("{}", format_single_line_entry(&entry));
|
debug!("{}", format_single_line_entry(&entry));
|
||||||
} else {
|
} else {
|
||||||
match entry.kind() {
|
match entry.kind() {
|
||||||
EntryKind::Version(_) | EntryKind::Prelude(_) => continue,
|
EntryKind::Version(_) | EntryKind::Prelude(_) => continue,
|
||||||
_ => log::info!("{:?}", entry.path()),
|
_ => info!("{:?}", entry.path()),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user