Skip to content
This repository has been archived by the owner on Dec 22, 2024. It is now read-only.

Commit

Permalink
Log output in local time, output program name/version on start in INF…
Browse files Browse the repository at this point in the history
…O level
  • Loading branch information
Ganneff committed Oct 3, 2024
1 parent 10e1cb8 commit e5f4813
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 8 deletions.
18 changes: 13 additions & 5 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ shlex = "1.3.0"
thiserror = "^1.0"
tmux_interface = { version = "^0.3.1", features = ["tmux_2_8", "cmd_alias"], default-features = false }
tracing = { version = "0.1.37", features = ["attributes"], default-features = false }
tracing-subscriber = { features = ["fmt", "ansi", "tracing-log"], default-features = false, version = "0.3.17" }
tracing-subscriber = { features = ["fmt", "ansi", "tracing-log", "chrono", "smallvec"], default-features = false, version = "0.3.18" }

[workspace]

Expand Down
8 changes: 6 additions & 2 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ use tmux_interface::{
SplitWindow, Tmux,
};
use tracing::{debug, error, event, info, trace, warn, Level};
use tracing_subscriber::FmtSubscriber;
use tracing_subscriber::{fmt::time::ChronoLocal, FmtSubscriber};

#[derive(Debug, Parser)]
#[clap(author, version, about)]
Expand Down Expand Up @@ -1246,6 +1246,9 @@ fn parse_line(line: &str, replace: &Option<String>, current_dir: &Path) -> Resul
}
}

static VERSION: &str = env!("CARGO_PKG_VERSION");
static APPLICATION: &str = env!("CARGO_PKG_NAME");

// Can't sensibly test main()
#[cfg(not(tarpaulin_include))]
/// main, start it all off
Expand All @@ -1267,6 +1270,7 @@ fn main() -> Result<()> {
.with_target(true)
.with_file(true)
.with_line_number(true)
.with_timer(ChronoLocal::rfc_3339())
.pretty();

let subscriber = match filter {
Expand All @@ -1283,7 +1287,7 @@ fn main() -> Result<()> {

tracing::subscriber::set_global_default(subscriber).expect("setting default subscriber failed");

info!("Program started");
info!("Starting {APPLICATION}, version {VERSION}");
event!(
Level::DEBUG,
msg = "Program started",
Expand Down

0 comments on commit e5f4813

Please sign in to comment.