diff options
author | Ben Morrison <ben@gbmor.dev> | 2019-09-04 10:27:48 -0400 |
---|---|---|
committer | Ben Morrison <ben@gbmor.dev> | 2019-09-04 10:27:48 -0400 |
commit | eca1e0ad03f3bf83f8548509291905363096f0af (patch) | |
tree | 3388dd9f05ed8afa8f2a48816e6640f73c3990bf /src/logging.rs | |
parent | 39894be3eac7d3410d460c8a7b52a6eae2caf841 (diff) | |
download | clinte-eca1e0ad03f3bf83f8548509291905363096f0af.tar.gz |
logging reflects executing username v0.3.4
Diffstat (limited to 'src/logging.rs')
-rw-r--r-- | src/logging.rs | 25 |
1 files changed, 17 insertions, 8 deletions
diff --git a/src/logging.rs b/src/logging.rs index 6340def..7b8bd2e 100644 --- a/src/logging.rs +++ b/src/logging.rs @@ -3,19 +3,28 @@ use std::fs::File; use chrono::offset::Utc; use simplelog::*; - -pub const FILE: &str = "/tmp/clinte.log"; +use users; + +lazy_static! { + static ref FILE: String = format!( + "/tmp/clinte_{}.log", + users::get_current_username() + .unwrap() + .into_string() + .unwrap() + ); +} pub fn init() { // If the log file exists on startup, // move and timestamp it so we get a // fresh log file. - if fs::metadata(FILE).is_ok() { - let mut newpath = FILE.to_string(); + if fs::metadata(FILE.clone()).is_ok() { + let mut new_file = FILE.clone(); let time = Utc::now().to_rfc3339(); - newpath.push_str("."); - newpath.push_str(&time); - fs::rename(FILE, newpath).unwrap(); + new_file.push_str("."); + new_file.push_str(&time); + fs::rename(FILE.clone(), new_file).unwrap(); } CombinedLogger::init(vec![ @@ -23,7 +32,7 @@ pub fn init() { WriteLogger::new( LevelFilter::Info, Config::default(), - File::create(FILE).unwrap(), + File::create(FILE.clone()).unwrap(), ), ]) .expect("Unable to initialize logging"); |