mirror of
https://github.com/EasyTier/EasyTier.git
synced 2024-11-16 11:42:27 +08:00
fix local time not work in musl (#20)
This commit is contained in:
parent
e5b3fb09e6
commit
31af413b03
|
@ -366,6 +366,7 @@ fn init_logger() {
|
|||
file_layer.set_ansi(false);
|
||||
let file_layer = file_layer
|
||||
.with_writer(file_appender)
|
||||
.with_timer(easytier_core::common::get_logger_timer_rfc3339())
|
||||
.with_filter(file_filter);
|
||||
|
||||
tracing_subscriber::Registry::default()
|
||||
|
|
|
@ -23,6 +23,7 @@ log = "0.4"
|
|||
thiserror = "1.0"
|
||||
auto_impl = "1.1.0"
|
||||
crossbeam = "0.8.4"
|
||||
time = "0.3"
|
||||
|
||||
gethostname = "0.4.3"
|
||||
|
||||
|
|
|
@ -7,3 +7,19 @@ pub mod netns;
|
|||
pub mod network;
|
||||
pub mod rkyv_util;
|
||||
pub mod stun;
|
||||
|
||||
pub fn get_logger_timer<F: time::formatting::Formattable>(
|
||||
format: F,
|
||||
) -> tracing_subscriber::fmt::time::OffsetTime<F> {
|
||||
unsafe {
|
||||
time::util::local_offset::set_soundness(time::util::local_offset::Soundness::Unsound)
|
||||
};
|
||||
let local_offset = time::UtcOffset::current_local_offset()
|
||||
.unwrap_or(time::UtcOffset::from_whole_seconds(0).unwrap());
|
||||
tracing_subscriber::fmt::time::OffsetTime::new(local_offset, format)
|
||||
}
|
||||
|
||||
pub fn get_logger_timer_rfc3339(
|
||||
) -> tracing_subscriber::fmt::time::OffsetTime<time::format_description::well_known::Rfc3339> {
|
||||
get_logger_timer(time::format_description::well_known::Rfc3339)
|
||||
}
|
||||
|
|
|
@ -15,6 +15,7 @@ mod peers;
|
|||
mod rpc;
|
||||
mod tunnels;
|
||||
|
||||
use common::get_logger_timer_rfc3339;
|
||||
use instance::instance::{Instance, InstanceConfigWriter};
|
||||
use tracing::level_filters::LevelFilter;
|
||||
use tracing_subscriber::{layer::SubscriberExt, util::SubscriberInitExt, EnvFilter, Layer};
|
||||
|
@ -53,7 +54,7 @@ fn init_logger() {
|
|||
file_layer.set_ansi(false);
|
||||
let file_layer = file_layer
|
||||
.with_writer(file_appender)
|
||||
.with_timer(tracing_subscriber::fmt::time::OffsetTime::local_rfc_3339().unwrap())
|
||||
.with_timer(get_logger_timer_rfc3339())
|
||||
.with_filter(file_filter);
|
||||
|
||||
// logger to console
|
||||
|
@ -63,7 +64,7 @@ fn init_logger() {
|
|||
.unwrap();
|
||||
let console_layer = tracing_subscriber::fmt::layer()
|
||||
.pretty()
|
||||
.with_timer(tracing_subscriber::fmt::time::OffsetTime::local_rfc_3339().unwrap())
|
||||
.with_timer(get_logger_timer_rfc3339())
|
||||
.with_writer(std::io::stderr)
|
||||
.with_filter(console_filter);
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user