src/tools/file_logger.rs: change timestamp format to rfc3339

This commit is contained in:
Dietmar Maurer 2019-04-03 08:58:43 +02:00
parent 92da93b245
commit 3489936ebb
1 changed files with 3 additions and 3 deletions

View File

@ -1,5 +1,5 @@
use failure::*;
use chrono::Local;
use chrono::{TimeZone, Local};
use std::io::Write;
/// Log messages with timestamps into files
@ -18,6 +18,7 @@ use std::io::Write;
/// ```
#[derive(Debug)]
pub struct FileLogger {
file: std::fs::File,
to_stdout: bool,
@ -54,8 +55,7 @@ impl FileLogger {
stdout.write(b"\n").unwrap();
}
let line = format!("{}: {}\n", Local::now().format("%b %e %T"), msg);
let line = format!("{}: {}\n", Local.timestamp(Local::now().timestamp(), 0).to_rfc3339(), msg);
self.file.write(line.as_bytes()).unwrap();
}
}