Skip to content

Commit

Permalink
Merge pull request #60 from WIZeaz/log-format
Browse files Browse the repository at this point in the history
feat: replace "RAP_FRONT" with "RAP"; use ISO 8601 timestamp in log
  • Loading branch information
hxuhack authored Oct 16, 2024
2 parents 90385e2 + 0921955 commit a9e3c29
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions rap/src/utils/log.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use chrono::{Local, Timelike};
use chrono::Local;
use fern::colors::{Color, ColoredLevelConfig};
use fern::{self, Dispatch};
use log::LevelFilter;
Expand Down Expand Up @@ -26,18 +26,16 @@ pub fn init_log() -> Result<(), fern::InitError> {
.trace(Color::BrightBlack);

let color_level = color_line.info(Color::Green);

let stderr_dispatch = Dispatch::new()
.format(move |callback, args, record| {
let time_now = Local::now();
let now = Local::now();
callback.finish(format_args!(
"{}{}:{}|RAP-FRONT|{}{}|: {}\x1B[0m",
"{}{}|RAP|{}{}|: {}\x1B[0m",
format_args!(
"\x1B[{}m",
color_line.get_color(&record.level()).to_fg_str()
),
time_now.hour(),
time_now.minute(),
now.format("%H:%M:%S%.3f").to_string(),
color_level.color(record.level()),
format_args!(
"\x1B[{}m",
Expand Down

0 comments on commit a9e3c29

Please sign in to comment.