From 5764f93c4e803cba39c0f06f8ced0cab1d229a25 Mon Sep 17 00:00:00 2001 From: Aditya Bisht Date: Tue, 8 Oct 2024 11:43:28 +0530 Subject: [PATCH] fix: take version during logging via env --- src/logger.rs | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/logger.rs b/src/logger.rs index 9652b8a..c486d8d 100644 --- a/src/logger.rs +++ b/src/logger.rs @@ -66,7 +66,10 @@ fn init_logger() -> slog::Logger { slog_async::Async::new(slog::Duplicate(log_terminal_json_drain, log_file_drain).fuse()) .build() .fuse(); - slog::Logger::root(log_drain, o!("version" => env!("CARGO_PKG_VERSION"))) + slog::Logger::root( + log_drain, + o!("version" => env::var("CARGO_PKG_VERSION").unwrap_or_else(|_| "unknown".to_string())), + ) } else { // Otherwise, use formatted text for terminal and JSON for file logging. let log_drain = @@ -75,6 +78,9 @@ fn init_logger() -> slog::Logger { .overflow_strategy(slog_async::OverflowStrategy::Block) // Set overflow strategy to block when the channel is full. .build() .fuse(); - slog::Logger::root(log_drain, o!("version" => env!("CARGO_PKG_VERSION"))) + slog::Logger::root( + log_drain, + o!("version" => env::var("CARGO_PKG_VERSION").unwrap_or_else(|_| "unknown".to_string())), + ) } }