From 9b4156888167c77c4b253e78a2c750b216fc2942 Mon Sep 17 00:00:00 2001 From: Sylvain Migaud Date: Thu, 30 Sep 2021 06:09:30 +0000 Subject: [PATCH] Place date at the begining of the log file name --- CHANGELOG.md | 1 + common/frontend/src/lib.rs | 2 +- voxygen/src/main.rs | 8 +++++--- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3fb375711c..84aedd47f0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -16,6 +16,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Changed - Made dungeon tiers 3, 4, and 5 more common +- Put date at the begining of the log file instead of the end to allow MIME type recognition - Tweaked CR and exp calculation formula ### Removed diff --git a/common/frontend/src/lib.rs b/common/frontend/src/lib.rs index 6b78cf750e..1f5b389f48 100644 --- a/common/frontend/src/lib.rs +++ b/common/frontend/src/lib.rs @@ -113,7 +113,7 @@ where if let Some((path, file)) = log_path_file { match fs::create_dir_all(path) { Ok(_) => { - let file_appender = tracing_appender::rolling::daily(path, file); + let file_appender = tracing_appender::rolling::never(path, file); // It is actually rolling daily since the log name is changing daily let (non_blocking_file, file_guard) = tracing_appender::non_blocking(file_appender); guards.push(file_guard); file_setup = true; diff --git a/voxygen/src/main.rs b/voxygen/src/main.rs index 98e97f5db7..cd6b98eab0 100644 --- a/voxygen/src/main.rs +++ b/voxygen/src/main.rs @@ -19,6 +19,7 @@ use veloren_voxygen::{ GlobalState, }; +use chrono::Utc; #[cfg(feature = "hot-reloading")] use common::assets; use common::clock::Clock; @@ -39,8 +40,9 @@ fn main() { .unwrap_or_else(|| userdata_dir.join("voxygen").join("logs")); // Init logging and hold the guards. - const LOG_FILENAME: &str = "voxygen.log"; - let _guards = common_frontend::init_stdout(Some((&logs_dir, LOG_FILENAME))); + let now = Utc::now(); + let log_filename = format!("{}_voxygen.log", now.format("%Y-%m-%d")); + let _guards = common_frontend::init_stdout(Some((&logs_dir, &log_filename))); info!("Using userdata dir at: {}", userdata_dir.display()); @@ -117,7 +119,7 @@ fn main() { Panic Payload: {:?}\n\ PanicInfo: {}\n\ Game version: {} [{}]", - logs_dir.join("voxygen.log.").display(), + logs_dir.join(&log_filename).display(), reason, panic_info, common::util::GIT_HASH.to_string(),