time-rs / time

The most used Rust library for date and time handling.
https://time-rs.github.io
Apache License 2.0
1.06k stars 261 forks source link

The log CAN NOT display the time correctly in the LINUX with tracing_subscriber::fmt().with_timer(LocalTime::rfc_3339()) #617

Closed TQLeung closed 10 months ago

TQLeung commented 10 months ago

Bug Report

The log show < unknown time > INFO actix_server:: accept : accept thread stopped in the Linux Centos7

relate issue link

Version ^0.3.0

Platform

Linux localhost.localdomain 3.10.0-1160.92.1.el7.x86_64 #1 SMP Tue Jun 20 11:48:01 UTC 2023 x86_64 x86_64 x86_64 GNU/Linux

Crates

[dependencies]
actix-web = "4.4.0"
sea-orm = { version = "0.12.2", features = [ "sqlx-mysql", "runtime-tokio-rustls", "macros", "mock" ] }
log = "0.4.20"
futures = "0.3.28"
sea-orm-migration = "0.12.2"
serde_json = "1.0.64"
serde_urlencoded = "0.7.0"
serde = { version = "1.0.64", features = ["derive"] }
chrono = "0.4.28"
uuid = { version = "1.4.1", features = ["serde", "v4"] }
tracing-subscriber = { version = "0.3.17", features = ["env-filter", "local-time"] }
async-graphql = "6.0.5"
async-graphql-actix-web = "6.0.5"
error-chain = "0.12.4"
rand = "0.8.5"
structopt = "0.3"
once_cell = "1"
regex = "1.9"
config = "0.13"

Description

in the WINDOW11 is correct, BUT THE LOG IN THE LINUX IS ERROR, THE LOGS as BELOW:

2023-09-10T17:26:29.69398601+08:00

< unknown time >

when server start, the log can display correct time info,but after that, the time info change to < unknown time > THE problem AT THE BEGINNING OF THE EACH LINE

2023-09-10T17:26:29.69398601+08:00  INFO actix_server::builder: starting 2 workers
2023-09-10T17:26:29.69435411+08:00  INFO actix_server::server: Actix runtime found; starting in Actix runtime
< unknown time >  INFO sqlx::query: summary="SET sql_mode=(SELECT CONCAT(@@sql_mode, ',PIPES_AS_CONCAT,NO_ENGINE_SUBSTITUTION')),time_zone='+00:00',NAMES …" db.statement="\n\nSET\n  sql_mode =(\n    SELECT\n      CONCAT(\n        @ @sql_mode,\n        ',PIPES_AS_CONCAT,NO_ENGINE_SUBSTITUTION'\n      )\n  ),\n  time_zone = '+00:00',\n  NAMES utf8mb4 COLLATE utf8mb4_unicode_ci;\n" rows_affected=0 rows_returned=0 elapsed=1.5326ms
< unknown time >  INFO actix_server::server: SIGINT received; starting forced shutdown
< unknown time >  INFO actix_server::accept: accept thread stopped
< unknown time >  INFO actix_server::worker: shutting down idle worker
< unknown time >  INFO actix_server::worker: shutting down idle worker

Code

tracing-subscriber = { version = "0.3.17", features = ["env-filter", "local-time"] }
std::env::set_var("RUST_LOG", "DEBUG");
tracing_subscriber::fmt::time::LocalTime::rfc_3339();
tracing_subscriber::fmt()
        .with_timer(LocalTime::rfc_3339())
        .init();
jhpratt commented 10 months ago

Is your async runtime multi-threaded? If so, calls to OffsetDateTime::now_local will fail on Linux to avoid UB.

jhpratt commented 10 months ago

Closing per my previous comment. If this is not the case, please state so.