aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Duerr <contact@christianduerr.com>2018-11-09 22:15:59 +0100
committerChristian Duerr <contact@christianduerr.com>2018-11-10 18:21:43 +0100
commite66f23ad97c8df42192d07650109d42de3c767c9 (patch)
treea31d4888756a77becea5bb981469ab064f25fc50
parenta951ad2be9d033185dcceb83261b6ffcd57897d0 (diff)
downloadalacritty-e66f23ad97c8df42192d07650109d42de3c767c9.tar.gz
alacritty-e66f23ad97c8df42192d07650109d42de3c767c9.zip
Add timestamp to log messages
To help with debugging Alacritty issues, a timestamp and the error level have been added to all log messages. All log messages now follow this format: [YYYY-MM-DD HH:MM] [LEVEL] Message
-rw-r--r--Cargo.lock1
-rw-r--r--Cargo.toml1
-rw-r--r--src/lib.rs1
-rw-r--r--src/logging.rs12
4 files changed, 13 insertions, 2 deletions
diff --git a/Cargo.lock b/Cargo.lock
index 1c48899d..bc02f81f 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -56,6 +56,7 @@ dependencies = [
"static_assertions 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)",
"tempfile 3.0.4 (registry+https://github.com/rust-lang/crates.io-index)",
"terminfo 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)",
+ "time 0.1.40 (registry+https://github.com/rust-lang/crates.io-index)",
"unicode-width 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)",
"url 1.7.2 (registry+https://github.com/rust-lang/crates.io-index)",
"vte 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)",
diff --git a/Cargo.toml b/Cargo.toml
index 10748987..a5385ba3 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -49,6 +49,7 @@ image = "0.20.1"
static_assertions = "0.2.5"
terminfo = "0.6.1"
url = "1.7.1"
+time = "0.1.40"
[target.'cfg(any(target_os = "linux", target_os = "freebsd", target_os="dragonfly", target_os="openbsd"))'.dependencies]
x11-dl = "2"
diff --git a/src/lib.rs b/src/lib.rs
index 1d393d1a..7ba3538b 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -64,6 +64,7 @@ extern crate xdg;
extern crate base64;
extern crate terminfo;
extern crate url;
+extern crate time;
#[macro_use]
pub mod macros;
diff --git a/src/logging.rs b/src/logging.rs
index 71eaf822..bca8a7f0 100644
--- a/src/logging.rs
+++ b/src/logging.rs
@@ -19,6 +19,7 @@
//! log-level is sufficient for the level configured in `cli::Options`.
use cli;
use log::{self, Level};
+use time;
use std::env;
use std::fs::{File, OpenOptions};
@@ -121,12 +122,19 @@ impl log::Log for Logger {
fn log(&self, record: &log::Record) {
if self.enabled(record.metadata()) && record.target().starts_with("alacritty") {
+ let msg = format!(
+ "[{}] [{}] {}\n",
+ time::now().strftime("%F %R").unwrap(),
+ record.level(),
+ record.args()
+ );
+
if let Ok(ref mut logfile) = self.logfile.lock() {
- let _ = logfile.write_all(format!("{}\n", record.args()).as_ref());
+ let _ = logfile.write_all(msg.as_ref());
}
if let Ok(ref mut stdout) = self.stdout.lock() {
- let _ = stdout.write_all(format!("{}\n", record.args()).as_ref());
+ let _ = stdout.write_all(msg.as_ref());
}
match record.level() {