mirror of
https://github.com/alacritty/alacritty.git
synced 2024-11-18 13:55:23 -05:00
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
This commit is contained in:
parent
a951ad2be9
commit
e66f23ad97
4 changed files with 13 additions and 2 deletions
1
Cargo.lock
generated
1
Cargo.lock
generated
|
@ -56,6 +56,7 @@ dependencies = [
|
||||||
"static_assertions 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
"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)",
|
"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)",
|
"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)",
|
"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)",
|
"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)",
|
"vte 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
|
|
|
@ -49,6 +49,7 @@ image = "0.20.1"
|
||||||
static_assertions = "0.2.5"
|
static_assertions = "0.2.5"
|
||||||
terminfo = "0.6.1"
|
terminfo = "0.6.1"
|
||||||
url = "1.7.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]
|
[target.'cfg(any(target_os = "linux", target_os = "freebsd", target_os="dragonfly", target_os="openbsd"))'.dependencies]
|
||||||
x11-dl = "2"
|
x11-dl = "2"
|
||||||
|
|
|
@ -64,6 +64,7 @@ extern crate xdg;
|
||||||
extern crate base64;
|
extern crate base64;
|
||||||
extern crate terminfo;
|
extern crate terminfo;
|
||||||
extern crate url;
|
extern crate url;
|
||||||
|
extern crate time;
|
||||||
|
|
||||||
#[macro_use]
|
#[macro_use]
|
||||||
pub mod macros;
|
pub mod macros;
|
||||||
|
|
|
@ -19,6 +19,7 @@
|
||||||
//! log-level is sufficient for the level configured in `cli::Options`.
|
//! log-level is sufficient for the level configured in `cli::Options`.
|
||||||
use cli;
|
use cli;
|
||||||
use log::{self, Level};
|
use log::{self, Level};
|
||||||
|
use time;
|
||||||
|
|
||||||
use std::env;
|
use std::env;
|
||||||
use std::fs::{File, OpenOptions};
|
use std::fs::{File, OpenOptions};
|
||||||
|
@ -121,12 +122,19 @@ impl log::Log for Logger {
|
||||||
|
|
||||||
fn log(&self, record: &log::Record) {
|
fn log(&self, record: &log::Record) {
|
||||||
if self.enabled(record.metadata()) && record.target().starts_with("alacritty") {
|
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() {
|
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() {
|
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() {
|
match record.level() {
|
||||||
|
|
Loading…
Reference in a new issue