Skip to content

Commit

Permalink
Add build identifier
Browse files Browse the repository at this point in the history
  • Loading branch information
hillu committed Feb 3, 2025
1 parent b655fe4 commit f5dc95a
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 4 deletions.
1 change: 1 addition & 0 deletions INSTALL.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ Build binary, install:
$ cargo build --release
$ sudo install -m755 target/release/laurel /usr/local/sbin/laurel
```
If the environment variable `LAUREL_BUILD_ID` is set at build time, it is output after the version number.

## …or use one of the provided binaries

Expand Down
20 changes: 16 additions & 4 deletions src/bin/laurel/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,13 @@ use laurel::logger;
use laurel::rotate::FileRotate;
use laurel::types::Event;

const fn build_id() -> &'static str {
match option_env!("LAUREL_BUILD_ID") {
None => "generic",
Some(s) => s,
}
}

#[derive(Default, Serialize)]
struct Stats {
lines: u64,
Expand Down Expand Up @@ -162,7 +169,7 @@ fn run_app() -> Result<(), anyhow::Error> {
}

if matches.opt_present("v") {
println!("{}", laurel::VERSION);
println!("{} ({})", laurel::VERSION, build_id());
return Ok(());
}

Expand Down Expand Up @@ -211,7 +218,7 @@ fn run_app() -> Result<(), anyhow::Error> {
};

if matches.opt_present("d") {
println!("Laurel {}: Config ok.", laurel::VERSION);
println!("Laurel {} ({}): Config ok.", laurel::VERSION, build_id());
return Ok(());
}

Expand Down Expand Up @@ -284,7 +291,12 @@ fn run_app() -> Result<(), anyhow::Error> {

// Initial setup is done at this point.

log::info!("Started {} running version {}", &args[0], laurel::VERSION);
log::info!(
"Started {} running version {} ({})",
&args[0],
laurel::VERSION,
build_id()
);
log::info!(
"Running with EUID {} using config {}",
Uid::effective().as_raw(),
Expand Down Expand Up @@ -425,7 +437,7 @@ fn run_app() -> Result<(), anyhow::Error> {
if statusreport_period_t.as_secs() > 0
&& statusreport_last_t.elapsed()? >= statusreport_period_t
{
log::info!("Laurel version {}", laurel::VERSION);
log::info!("Laurel version {} ({})", laurel::VERSION, build_id());
log::info!(
"Parsing stats (until now): processed {} lines {} events with {} errors in total",
&stats.lines, &stats.events, &stats.errors );
Expand Down

0 comments on commit f5dc95a

Please sign in to comment.