Skip to content

Commit 61b3f5f

Browse files
authored
Merge pull request #538 from NotEvenANeko/refactor/spdlog
refactor: refactor to `spdlog-rs` instead of `tracing`
2 parents 1bcb3b3 + 4f96964 commit 61b3f5f

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

67 files changed

+809
-578
lines changed

Cargo.lock

Lines changed: 277 additions & 64 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,7 @@ rustix = { version = "1", features = ["process", "stdio"] }
2525
libc = "0.2.159"
2626
reqwest = { version = "0.13", default-features = false, features = ["http2"] }
2727
rustls = { version = "0.23", default-features = false, features = ["ring", "tls12"], optional = true }
28-
tracing = "0.1.40"
29-
tracing-subscriber = { version = "0.3.18", features = ["env-filter"] }
28+
spdlog-rs = { version = "0.5.2", features = ["multi-thread", "source-location", "log"] }
3029
console-subscriber = { version = "0.5.0", optional = true }
3130
ratatui = "0.30.0"
3231
ansi-to-tui = "8.0.0"
@@ -44,7 +43,6 @@ clap_complete = { version = "4.5", features = ["unstable-dynamic"] }
4443
clap_lex = "0.7.4"
4544
fs4 = "0.13.1"
4645
fs_extra = "1.3.0"
47-
tracing-appender = "0.2.3"
4846
dirs = "6.0.0"
4947
termtree = "0.5.1"
5048
textwrap = "0.16.2"
@@ -56,6 +54,7 @@ debversion = "0.5"
5654
which = "8"
5755
rayon = "1.11.0"
5856
humantime = "2.3"
57+
env_filter = "0.1.4"
5958

6059
# oma crates
6160
oma-utils = { path = "./oma-utils", features = ["dbus", "human-bytes"] }

apt-auth-config/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,6 @@ license = "MIT"
77

88
[dependencies]
99
thiserror = "2"
10-
tracing = "0.1"
10+
spdlog-rs = "0.5"
1111
rust-netrc = "0.1"
1212
url = "2.5"

oma-console/Cargo.toml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,10 @@ license = "MIT"
88
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
99

1010
[dependencies]
11+
chrono = { version = "0.4.38", optional = true }
1112
console = { version = "0.16", optional = true }
1213
indicatif = { version = "0.18", optional = true }
13-
tracing = { version = "0.1", optional = true }
14-
tracing-subscriber = { version = "0.3", optional = true }
14+
spdlog-rs = "0.5"
1515
ratatui = { version = "0.30", optional = true }
1616
# https://github.com/async-rs/async-std/issues/1055
1717
# https://github.com/tokio-rs/tokio/issues/5535
@@ -21,7 +21,7 @@ textwrap = { version = "0.16", optional = true }
2121
aho-corasick = { version = "1.1.3", optional = true }
2222

2323
[features]
24-
print = ["dep:tracing", "dep:tracing-subscriber", "dep:textwrap", "dep:console", "dep:termbg"]
24+
print = ["dep:chrono", "dep:textwrap", "dep:console", "dep:termbg"]
2525
pager = ["dep:ratatui", "dep:ansi-to-tui", "dep:console", "dep:aho-corasick"]
2626
progress_bar_style = ["dep:indicatif"]
2727
default = ["print", "pager", "progress_bar_style"]

oma-console/examples/msg.rs

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,15 @@
1-
use oma_console::OmaLayer;
2-
use tracing_subscriber::{prelude::__tracing_subscriber_SubscriberExt, util::SubscriberInitExt};
1+
use oma_console::OmaFormatter;
32

43
fn main() {
5-
tracing_subscriber::registry().with(OmaLayer::new()).init();
6-
tracing::info!("Welcome");
7-
tracing::debug!("Hello");
8-
tracing::info!("I'am fine");
9-
tracing::warn!("Thank you");
10-
tracing::error!("and you?");
4+
spdlog::default_logger()
5+
.sinks()
6+
.iter()
7+
.for_each(|s| s.set_formatter(Box::new(OmaFormatter::default())));
8+
spdlog::default_logger().set_level_filter(spdlog::LevelFilter::All);
9+
10+
spdlog::info!("Welcome");
11+
spdlog::debug!("Hello");
12+
spdlog::info!("I'am fine");
13+
spdlog::warn!("Thank you");
14+
spdlog::error!("and you?");
1115
}

oma-console/src/lib.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,14 @@ pub mod pb;
2626
#[cfg(feature = "print")]
2727
pub mod writer;
2828

29+
#[cfg(feature = "print")]
30+
pub mod terminal;
31+
2932
#[cfg(feature = "print")]
3033
pub mod print;
3134

3235
#[cfg(feature = "print")]
33-
pub use print::OmaLayer;
36+
pub use print::OmaFormatter;
3437

3538
#[cfg(feature = "print")]
3639
pub use console;

oma-console/src/pager.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@ use ratatui::{
2222
},
2323
widgets::Borders,
2424
};
25+
use spdlog::debug;
2526
use termbg::Theme;
26-
use tracing::debug;
2727

2828
use crate::{print::OmaColorFormat, writer::Writer};
2929

0 commit comments

Comments
 (0)