diff --git a/Cargo.lock b/Cargo.lock index cda6f86..03b9ad0 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1671,11 +1671,12 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "tmpo" -version = "2.5.0" +version = "2.5.1" dependencies = [ "assert_cli 0.6.3 (registry+https://github.com/rust-lang/crates.io-index)", "assert_cmd 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)", "base64 0.13.0 (registry+https://github.com/rust-lang/crates.io-index)", + "chrono 0.4.15 (registry+https://github.com/rust-lang/crates.io-index)", "clap 3.0.0-beta.2 (registry+https://github.com/rust-lang/crates.io-index)", "colored 2.0.0 (registry+https://github.com/rust-lang/crates.io-index)", "convert_case 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", diff --git a/Cargo.toml b/Cargo.toml index 05be3e2..b2ec01d 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "tmpo" description = "Command line utility to create new workspaces based on predefined templates" -version = "2.5.0" +version = "2.5.1" authors = ["Thomas Pöhlmann "] edition = "2018" license = "MIT" @@ -13,7 +13,6 @@ serde_json = "1.0.62" serde_yaml = "0.8.17" dirs = "3.0.1" log = "0.4.14" -log4rs = "1.0.0" git2 = "0.13" colored = "2.0.0" dialoguer = "0.7.1" @@ -27,6 +26,10 @@ base64 = "0.13.0" semver = "0.11.0" convert_case = "0.4.0" linked_hash_set = "0.1.4" +chrono = "0.4.13" + +[dependencies.log4rs] +version = "1.0.0" [dependencies.reqwest] version = "0.11.0" diff --git a/changelog.md b/changelog.md index ed9151d..0cce198 100644 --- a/changelog.md +++ b/changelog.md @@ -1,5 +1,11 @@ # What's new in Tmpo +### 2.5.1 + +### Fix + +- Setup timebased rolling log files + ## 2.5.0 ### Feature diff --git a/src/logger/mod.rs b/src/logger/mod.rs index c688fb9..a455c62 100644 --- a/src/logger/mod.rs +++ b/src/logger/mod.rs @@ -1,3 +1,4 @@ +use chrono::Local; use log::LevelFilter; use log4rs::{ append::{ @@ -21,7 +22,7 @@ pub fn init() { .build(); // Logging to log file - let logfile_path = config::directory().join("log/output.log"); + let logfile_path = config::directory().join(get_log_file_name()); let logfile = FileAppender::builder() .encoder(Box::new(PatternEncoder::new( @@ -47,3 +48,9 @@ pub fn init() { log4rs::init_config(config).unwrap(); } + +fn get_log_file_name() -> String { + let local = Local::now(); + let timestamp = local.format("%Y-%m-%d").to_string(); + return String::from("log/") + ×tamp + ".log"; +}