【发布时间】:2022-01-25 22:40:44
【问题描述】:
我正在构建一个 Rust 应用程序,我正在使用 Simple Logger 来记录我的应用程序的初始化。我的main.rs 看起来像这样:
use log::info;
use simple_logger::SimpleLogger;
fn main() {
SimpleLogger::new().init().unwrap();
let (event_loop, mut interface) = create_interface();
info!("Game interface created");
上面的代码出错了:
thread 'main' panicked at 'Could not determine the UTC offset on this system. Possible causes are that the time crate does not implement "local_offset_at" on your system, or that you are running in a multi-threaded environment and the time crate is returning "None" from "local_offset_at" to avoid unsafe behaviour. See the time crate's documentation for more information. (https://time-rs.github.io/internal-api/time/index.html#feature-flags): IndeterminateOffset', /home/athul/.cargo/registry/src/github.com-1ecc6299db9ec823/simple_logger-1.16.0/src/lib.rs:409:85
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
我试过了:
- 将
try_current_local_offset与时间箱一起使用 - 使用计时
但错误仍然存在。我可能没有为我的应用程序正确初始化时间。最好(也是最简单)的方法是什么?
【问题讨论】:
-
我无法使用最小示例重现您的问题。您是否已经尝试过使用
.with_utc_timestamps()就像这里提到的github.com/ravenclaw900/DietPi-Dashboard/issues/82 和github.com/ravenclaw900/DietPi-Dashboard/commit/… 一样? -
这行得通 :) 请将此作为答案并将其标记为已解决 :) 谢谢!