summary refs log tree commit diff stats
path: root/src/logging.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/logging.rs')
-rw-r--r--src/logging.rs25
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");
d2200; background-color: #fff0f0 } /* Literal.String.Double */ .highlight .se { color: #0044dd; background-color: #fff0f0 } /* Literal.String.Escape */ .highlight .sh { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Heredoc */ .highlight .si { color: #3333bb; background-color: #fff0f0 } /* Literal.String.Interpol */ .highlight .sx { color: #22bb22; background-color: #f0fff0 } /* Literal.String.Other */ .highlight .sr { color: #008800; background-color: #fff0ff } /* Literal.String.Regex */ .highlight .s1 { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Single */ .highlight .ss { color: #aa6600; background-color: #fff0f0 } /* Literal.String.Symbol */ .highlight .bp { color: #003388 } /* Name.Builtin.Pseudo */ .highlight .fm { color: #0066bb; font-weight: bold } /* Name.Function.Magic */ .highlight .vc { color: #336699 } /* Name.Variable.Class */ .highlight .vg { color: #dd7700 } /* Name.Variable.Global */ .highlight .vi { color: #3333bb } /* Name.Variable.Instance */ .highlight .vm { color: #336699 } /* Name.Variable.Magic */ .highlight .il { color: #0000DD; font-weight: bold } /* Literal.Number.Integer.Long */
void cmd_alias_add_shows_usage_when_no_args(void** state);
void cmd_alias_add_shows_usage_when_no_value(void** state);
void cmd_alias_remove_shows_usage_when_no_args(void** state);
void cmd_alias_show_usage_when_invalid_subcmd(void** state);
void cmd_alias_add_adds_alias(void** state);
void cmd_alias_add_shows_message_when_exists(void** state);
void cmd_alias_remove_removes_alias(void** state);
void cmd_alias_remove_shows_message_when_no_alias(void** state);
void cmd_alias_list_shows_all_aliases(void** state);