src/tools/file_logger.rs: change timestamp format to rfc3339
This commit is contained in:
parent
92da93b245
commit
3489936ebb
|
@ -1,5 +1,5 @@
|
||||||
use failure::*;
|
use failure::*;
|
||||||
use chrono::Local;
|
use chrono::{TimeZone, Local};
|
||||||
use std::io::Write;
|
use std::io::Write;
|
||||||
|
|
||||||
/// Log messages with timestamps into files
|
/// Log messages with timestamps into files
|
||||||
|
@ -18,6 +18,7 @@ use std::io::Write;
|
||||||
/// ```
|
/// ```
|
||||||
|
|
||||||
|
|
||||||
|
#[derive(Debug)]
|
||||||
pub struct FileLogger {
|
pub struct FileLogger {
|
||||||
file: std::fs::File,
|
file: std::fs::File,
|
||||||
to_stdout: bool,
|
to_stdout: bool,
|
||||||
|
@ -54,8 +55,7 @@ impl FileLogger {
|
||||||
stdout.write(b"\n").unwrap();
|
stdout.write(b"\n").unwrap();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let line = format!("{}: {}\n", Local.timestamp(Local::now().timestamp(), 0).to_rfc3339(), msg);
|
||||||
let line = format!("{}: {}\n", Local::now().format("%b %e %T"), msg);
|
|
||||||
self.file.write(line.as_bytes()).unwrap();
|
self.file.write(line.as_bytes()).unwrap();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue