Skip to content

Commit 161b9ae

Browse files
committed
refactor(bundle): use tracing logging features
1 parent 3661eb2 commit 161b9ae

File tree

3 files changed

+27
-9
lines changed

3 files changed

+27
-9
lines changed

unionvisor/src/bundle.rs

+19-6
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ use std::{
99
use color_eyre::owo_colors::OwoColorize;
1010
use serde::{Deserialize, Serialize};
1111
use thiserror::Error;
12-
use tracing::{debug, error, field::display as as_display};
12+
use tracing::{debug, error, field::display as as_display, info};
1313

1414
/// Bundles should have the following structure on the filesystem:
1515
///
@@ -127,11 +127,11 @@ pub struct BundleMeta {
127127

128128
impl Display for Bundle {
129129
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
130-
writeln!(f, "BUNDLE INFO")?;
131-
writeln!(f, "┏━━━━━━━━━━━")?;
132-
writeln!(f, "┃ bundle: {self:?}")?;
133-
writeln!(f, "┃ genesis: {:?}", self.genesis_json().into_os_string())?;
134-
writeln!(f, "┃ versions:")?;
130+
// writeln!(f, "BUNDLE INFO")?;
131+
// writeln!(f, "┏━━━━━━━━━━━")?;
132+
// writeln!(f, "┃ bundle: {self:?}")?;
133+
// writeln!(f, "┃ genesis: {:?}", self.genesis_json().into_os_string())?;
134+
// writeln!(f, "┃ versions:")?;
135135

136136
let versions =
137137
fs::read_dir(self.versions_path()).expect("can't read contents of versions path");
@@ -195,6 +195,19 @@ impl Bundle {
195195
}
196196
}
197197

198+
pub fn log_bundle(bundle: &Bundle) {
199+
let versions = fs::read_dir(bundle.versions_path())
200+
.expect("can't read contents of versions path")
201+
.map(|v| {
202+
v.expect("can't read version in dir")
203+
.path()
204+
.into_os_string()
205+
})
206+
.collect::<Vec<_>>();
207+
208+
info!(target: "unionvisor", ?bundle, genesis=?bundle.genesis_json().into_os_string(), ?versions, "running with bundle" );
209+
}
210+
198211
#[derive(Debug, Error)]
199212
pub enum NewBundleError {
200213
#[error("cannot read bundle/meta.json")]

unionvisor/src/cli.rs

+4-2
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ use tracing::{field::display as as_display, info};
1313
use tracing_subscriber::filter::LevelFilter;
1414

1515
use crate::{
16-
bundle::{Bundle, NewBundleError, ValidateVersionPathError},
16+
bundle::{log_bundle, Bundle, NewBundleError, ValidateVersionPathError},
1717
init::{self, SetSeedsError},
1818
logging::LogFormat,
1919
supervisor::{self, RuntimeError},
@@ -208,7 +208,9 @@ impl RunCmd {
208208
fn run(&self, root: impl Into<PathBuf>, logformat: LogFormat) -> Result<(), RunError> {
209209
let root = root.into();
210210
let bundle = Bundle::new(self.bundle.clone())?;
211-
info!(target: "unionvisor", "running with bundle: {bundle}");
211+
212+
log_bundle(&bundle);
213+
212214
let symlinker = Symlinker::new(root.clone(), bundle);
213215
supervisor::run_and_upgrade(
214216
root,

unionvisor/src/supervisor.rs

+4-1
Original file line numberDiff line numberDiff line change
@@ -281,7 +281,10 @@ mod tests {
281281
use tracing_test::traced_test;
282282

283283
use super::*;
284-
use crate::{bundle::Bundle, testdata};
284+
use crate::{
285+
bundle::{log_bundle, Bundle},
286+
testdata,
287+
};
285288

286289
#[test]
287290
#[traced_test]

0 commit comments

Comments
 (0)