pub fn init_logger<P: AsRef<Path>>(
config_path: Option<P>,
) -> (WorkerGuard, LogConfig)Expand description
Initializes the global logger.
Reads the logging configuration (level, file name, formatting booleans and
time format) directly from a TOML file located at config_path. If the
file does not exist or cannot be parsed, sensible defaults are used.
Writing a Lib? Only use the tracing crate and its macros (info!, span!). Do not initialize anything.
Writing a Binary? Use tracing-subscriber to build the registry and handlers.
Missing dependency logs? Check your EnvFilter string rules and ensure the “log” feature is enabled on tracing-subscriber to catch legacy logs
Returns a WorkerGuard that must be kept alive to ensure logs are flushed to the file.
If later wanna do rsyslog (libc): https://docs.rs/syslog-tracing/0.3.1/syslog_tracing/struct.Syslog.html
Or the newcomer full rust: https://crates.io/crates/tracing-rfc-5424