0

I try to implement this actix tracing_log logging solution which leads to panic

thread 'main' panicked at 'Failed to set logger: SetLoggerError(())', mytool/src/main.rs:112:23
stack backtrace:
   0: rust_begin_unwind
             at /rustc/18bf6b4f01a6feaf7259b/library/std/src/panicking.rs:475
   1: core::panicking::panic_fmt
             at /rustc/18bf6b4f01a6feaf7259b/library/core/src/panicking.rs:85
   2: core::option::expect_none_failed
             at /rustc/18bf6b4f01a6feaf7259b/library/core/src/option.rs:1221
   3: mytool::main::{{closure}}
   4: std::thread::local::LocalKey<T>::with
   5: tokio::macros::scoped_tls::ScopedKey<T>::set
   6: <core::future::from_generator::GenFuture<T> as core::future::future::Future>::poll
   7: std::thread::local::LocalKey<T>::with
   8: tokio::macros::scoped_tls::ScopedKey<T>::set
   9: tokio::runtime::basic_scheduler::BasicScheduler<P>::block_on
  10: tokio::runtime::context::enter
  11: tokio::runtime::handle::Handle::enter
  12: actix_rt::builder::SystemRunner::block_on
  13: mytool::main
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
Panic in Arbiter thread.

backtrace isn't clear about implications - how to figure out why panic?

til
  • 832
  • 11
  • 27

1 Answers1

1

this article mentions that LogTracer::init() should be done first thing in main. Doing so lead to following panic

thread 'main' panicked at 'Builder::init should not be called after logger initialized: SetLoggerError(())', /usr/local/cargo/registry/src/github.com-1ecc6299db9ec823/env_logger-0.6.2/src/lib.rs:715:25
stack backtrace:
...

apparently there was an env_logger initialized further down, which interfered with LogTracer

Removing the env_logger fixed the issue.

til
  • 832
  • 11
  • 27