From 18d806987684804a37dc4bb263a8a3e95097131f Mon Sep 17 00:00:00 2001 From: Svyatoslav Nikolsky Date: Mon, 7 Feb 2022 17:46:03 +0300 Subject: [PATCH] Fix issues from cargo deny (#1311) * update libp2p-core (RUSTSEC-2022-0009) * update thread_local (RUSTSEC-2022-0006) * time 0.2 -> time 0.3 * ignore RUSTSEC-2021-0130 * proper migration to time 0.3 * fix clippy? * Revert "fix clippy?" This reverts commit 53bc289631769071848e43976871304782486fed. --- relays/utils/Cargo.toml | 2 +- relays/utils/src/initialize.rs | 12 +++++++++--- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/relays/utils/Cargo.toml b/relays/utils/Cargo.toml index a08c3b3d688..7996ba72f87 100644 --- a/relays/utils/Cargo.toml +++ b/relays/utils/Cargo.toml @@ -19,7 +19,7 @@ log = "0.4.11" num-traits = "0.2" serde_json = "1.0" sysinfo = "0.15" -time = "0.2" +time = { version = "0.3", features = ["formatting", "local-offset", "std"] } thiserror = "1.0.26" # Bridge dependencies diff --git a/relays/utils/src/initialize.rs b/relays/utils/src/initialize.rs index 8c13a4d61cb..ad69a766e62 100644 --- a/relays/utils/src/initialize.rs +++ b/relays/utils/src/initialize.rs @@ -29,15 +29,21 @@ pub fn initialize_relay() { /// Initialize Relay logger instance. pub fn initialize_logger(with_timestamp: bool) { + let format = time::format_description::parse( + "[year]-[month]-[day] \ + [hour repr:24]:[minute]:[second] [offset_hour sign:mandatory]", + ) + .expect("static format string is valid"); + let mut builder = env_logger::Builder::new(); builder.filter_level(log::LevelFilter::Warn); builder.filter_module("bridge", log::LevelFilter::Info); builder.parse_default_env(); if with_timestamp { builder.format(move |buf, record| { - let timestamp = time::OffsetDateTime::try_now_local() - .unwrap_or_else(|_| time::OffsetDateTime::now_utc()) - .format("%Y-%m-%d %H:%M:%S %z"); + let timestamp = time::OffsetDateTime::now_local() + .unwrap_or_else(|_| time::OffsetDateTime::now_utc()); + let timestamp = timestamp.format(&format).unwrap_or_else(|_| timestamp.to_string()); let log_level = color_level(record.level()); let log_target = color_target(record.target());