Skip to content
Update Rust authored by Miki, Hiromitsu's avatar Miki, Hiromitsu
......@@ -98,6 +98,7 @@ strip = true
#[macro_use]
extern crate log;
use chrono::{DateTime, Local};
use env_logger::{fmt::Color, Env};
use log::Level;
use std::io::Write;
......@@ -114,12 +115,17 @@ fn main() {
Level::Warn => Color::Yellow,
Level::Error => Color::Red,
});
let timestamp =
DateTime::parse_from_rfc3339(buf.timestamp_millis().to_string().as_str())
.unwrap()
.with_timezone(&Local)
.format("%Y/%m/%d %H:%M:%S.%3f")
.to_string();
return match record.level() {
Level::Trace | Level::Debug | Level::Info => writeln!(
buf,
"{} {:.<5} {}: {}",
chrono::Local::now().format("%Y/%m/%d %H:%M:%S"),
timestamp,
level_style.value(record.level()),
record.target(),
record.args()
......@@ -127,7 +133,7 @@ fn main() {
Level::Error | Level::Warn => writeln!(
buf,
"{} {:.<5} {}: {} ({}:{})",
chrono::Local::now().format("%Y/%m/%d %H:%M:%S"),
timestamp,
level_style.value(record.level()),
record.target(),
record.args(),
......
......