zino-rs / zino

Next-generation framework for composable applications in Rust.
https://crates.io/crates/zino
MIT License
762 stars 52 forks source link

zino-core\src\application\tracing_subscriber.rs OffsetTime::local_rfc_3339() Linux系统上执行报错了 #114

Closed AdairStone closed 3 weeks ago

AdairStone commented 3 months ago
let local_offset_time = OffsetTime::local_rfc_3339().expect("could not get local offset");

建议使用chrono实现

我本地的示例

pub fn current_date() -> DateTime { //default FixedOffset::east_opt(0).unwrap() let local_offset = Local::now().offset().fix().local_minus_utc(); let fixed_offset = FixedOffset::east_opt(local_offset) .unwrap_or(FixedOffset::east_opt(8*3600).unwrap()); let r = Utc::now().with_timezone(&fixed_offset); return r; } fn format_date_ymdhms(date: DateTime) -> String { let fmt = "%Y-%m-%d %H:%M:%S%.3f"; return date.format(fmt).to_string(); } struct LogTimer;

impl FormatTime for LogTimer { fn format_time(&self, w: &mut tracingsubscriber::fmt::format::Writer<'>) -> std::fmt::Result { write!( w, "{}", format_date_ymdhms(current_date()) ) } }

photino commented 3 months ago

有报什么错吗 可以参考之前的这个Issue: https://github.com/zino-rs/zino/issues/98