time format is now with T separator

This commit is contained in:
Данила Горнушко 2024-06-03 13:48:55 +03:00
parent c803fcccbf
commit e28bd11aeb

View file

@ -136,13 +136,14 @@ fn init_logger(
app_log_path: Option<&Path>,
stat_log_path: Option<&Path>,
) -> Result<(), fern::InitError> {
let log_level = match verbosity {
0 => LevelFilter::Info,
1 => LevelFilter::Debug,
_ => LevelFilter::Trace,
};
let time_format_string = "%Y-%m-%dT%H:%M:%S%.3f";
let app_dispatch = app_log_path.map(|path| {
Dispatch::new()
.format(|out, message, record| {
@ -150,7 +151,7 @@ fn init_logger(
let message = message.to_string();
out.finish(format_args!(
"{} [{}] - {}",
now.format("%Y-%m-%d %H:%M:%S%.3f"),
now.format(time_format_string),
record.level(),
if record.target() == "stats10min" {
Stats10Min::nice_log_format(&message)
@ -171,7 +172,7 @@ fn init_logger(
let now = Local::now();
out.finish(format_args!(
"{} {}",
now.format("%Y-%m-%d %H:%M:%S%.3f"),
now.format(time_format_string),
message
))
})
@ -195,7 +196,7 @@ fn init_logger(
};
out.finish(format_args!(
"{} [{}] - {}",
now.format("%Y-%m-%d %H:%M:%S%.3f"),
now.format(time_format_string),
level,
if record.target() == "stats10min" {
Stats10Min::nice_log_format(&message)
@ -334,8 +335,12 @@ fn main() {
cur_stats.hail_since_startup > prev_stats.hail_since_startup,
cur_stats.noise_since_startup > prev_stats.noise_since_startup,
) {
(true, true) => info!(target: "detected", "Hail and noise detected, {cur_stats}"),
(true, false) => info!(target: "detected", "Hail detected, {cur_stats}"),
(true, true) => {
info!(target: "detected", "Hail and noise detected, {cur_stats}")
}
(true, false) => {
info!(target: "detected", "Hail detected, {cur_stats}")
}
(false, true) => {
if args.noise_logging {
info!(target: "detected", "Noise detected, {cur_stats}")