local time!!!!11!1

This commit is contained in:
lda
2026-04-13 00:58:45 +07:00 Unverified
parent e912e7c7b3
commit 820ce1bd3b
6 changed files with 40 additions and 8 deletions
+2 -1
View File
@@ -27,7 +27,8 @@ tokio = { version = "1", features = [
tokio-tungstenite = { version = "0.24", features = ["rustls-tls-webpki-roots"] }
toml = "0.8"
tracing = "0.1"
tracing-subscriber = { version = "0.3", features = ["env-filter", "fmt"] }
tracing-subscriber = { version = "0.3", features = ["env-filter", "fmt", "time"] }
time = { version = "0.3", features = ["formatting", "local-offset"] }
url = "2"
wakey = { path = "..", registry = "gitea" }
wakey-core = { path = "../wakey-core", registry = "gitea" }
+9 -1
View File
@@ -1,3 +1,6 @@
use time::UtcOffset;
use time::format_description::well_known::Rfc3339;
use tracing_subscriber::fmt::time::OffsetTime;
use tracing_subscriber::{EnvFilter, fmt, layer::SubscriberExt, util::SubscriberInitExt};
pub fn init(verbose: u8) {
@@ -7,7 +10,7 @@ pub fn init(verbose: u8) {
tracing_subscriber::registry()
.with(filter)
.with(fmt::layer())
.with(fmt::layer().with_timer(local_offset_timer()))
.init();
}
@@ -18,3 +21,8 @@ fn default_filter(verbose: u8) -> &'static str {
_ => "wakey_agent=trace,wakey=debug",
}
}
fn local_offset_timer() -> OffsetTime<Rfc3339> {
let offset = UtcOffset::current_local_offset().unwrap_or(UtcOffset::UTC);
OffsetTime::new(offset, Rfc3339)
}