Skip to content

Commit

Permalink
refactor: rename log feature to tracing
Browse files Browse the repository at this point in the history
Signed-off-by: Wenxuan Zhang <wenxuangm@gmail.com>
  • Loading branch information
wfxr committed Apr 27, 2024
1 parent 7c78f9d commit 9f40255
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 11 deletions.
4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ name = "rlt"
path = "src/lib.rs"

[features]
default = ["log", "rate_limit", "http"]
log = ["dep:log", "dep:tracing", "dep:tui-logger"]
default = ["tracing", "rate_limit", "http"]
tracing = ["dep:log", "dep:tracing", "dep:tui-logger"]
rate_limit = ["dep:governor"]
http = ["dep:http"]

Expand Down
14 changes: 7 additions & 7 deletions src/collector/tui.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ pub struct TuiCollector {
struct TuiCollectorState {
tm_win: TimeWindow,
finished: bool,
#[cfg(feature = "log")]
#[cfg(feature = "tracing")]
log: tui_log::LogState,
}

Expand All @@ -74,7 +74,7 @@ impl TuiCollector {
let state = TuiCollectorState {
tm_win: TimeWindow::Second,
finished: false,
#[cfg(feature = "log")]
#[cfg(feature = "tracing")]
log: tui_log::LogState::from_env()?,
};
Ok(Self { bench_opts, fps, res_rx, pause, cancel, auto_quit, state })
Expand Down Expand Up @@ -236,7 +236,7 @@ impl TuiCollector {
render_latency_hist(f, bot[1], hist, 7);
render_tips(f, rows[4]);

#[cfg(feature = "log")]
#[cfg(feature = "tracing")]
tui_log::render_logs(f, &self.state.log);
})?;
}
Expand Down Expand Up @@ -274,9 +274,9 @@ impl TuiCollector {
}
self.pause.send_replace(pause);
}
#[cfg(feature = "log")]
#[cfg(feature = "tracing")]
(Char('l'), _) => self.state.log.display = !self.state.log.display,
#[cfg(feature = "log")]
#[cfg(feature = "tracing")]
(code, _) if self.state.log.display => {
use tui_logger::TuiWidgetEvent::*;
let mut txn = |e| self.state.log.inner.transition(e);
Expand Down Expand Up @@ -583,7 +583,7 @@ fn render_tips(frame: &mut Frame, area: Rect) {
let tips = gen_tips([
("+/-", "Zoom in/out"),
("a", "Auto time window"),
#[cfg(feature = "log")]
#[cfg(feature = "tracing")]
("l", "Logs window"),
("p", "Pause"),
("q", "Quit"),
Expand Down Expand Up @@ -648,7 +648,7 @@ impl TimeWindow {
}
}

#[cfg(feature = "log")]
#[cfg(feature = "tracing")]
mod tui_log {
use super::*;

Expand Down
2 changes: 1 addition & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,5 +73,5 @@ pub use crate::{
status::{Status, StatusKind},
};

#[cfg(feature = "log")]
#[cfg(feature = "tracing")]
pub use tui_logger::tracing_subscriber_layer as tui_tracing_subscriber_layer;
2 changes: 1 addition & 1 deletion src/runner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ where
self.wait_if_paused().await;
let res = self.suite.bench(state, info).await;

#[cfg(feature = "log")]
#[cfg(feature = "tracing")]
if let Err(e) = &res {
log::error!("Error in iteration({info:?}): {:?}", e);
}
Expand Down

0 comments on commit 9f40255

Please sign in to comment.