This commit is contained in:
ntr
2019-08-22 22:35:18 +10:00
parent 682be021b7
commit b9f4a67e0c
3 changed files with 310 additions and 4 deletions
+3 -4
View File
@@ -55,13 +55,12 @@ mod warden;
use std::thread::{spawn};
use std::path::{Path};
use fern::colors::{Color, ColoredLevelConfig};
use iron::prelude::*;
use crossbeam_channel::{unbounded};
#[derive(Serialize)]
struct JsonLog {
time: String,
name: String,
module: String,
level: String,
msg: String,
}
@@ -78,7 +77,7 @@ fn setup_logger() -> Result<(), fern::InitError> {
let term = fern::Dispatch::new()
.format(move |out, message, record| {
out.finish(format_args!(
"{color_line}[{date}][{target}][{level}{color_line}] {message}\x1B[0m",
"{color_line}{date} {target} {level}{color_line} {message}\x1B[0m",
color_line = format_args!("\x1B[{}m", colors_line.get_color(&record.level()).to_fg_str()),
date = chrono::Local::now().format("%Y-%m-%d %H:%M:%S"),
target = record.target(),
@@ -92,7 +91,7 @@ fn setup_logger() -> Result<(), fern::InitError> {
.format(|out, message, record| {
let json = JsonLog {
time: chrono::Local::now().to_rfc3339(),
name: record.target().to_string(),
module: record.target().to_string(),
level: record.level().to_string(),
msg: message.to_string()
};