Skip to main content

init_logging

Function init_logging 

Source
pub fn init_logging(cli: &Cli) -> Result<()>
Expand description

Ported from createBeforeHook’s logger-setup half. Installs a tracing dispatcher built from Cli’s logging flags as the process-wide default.

Tolerates being called more than once per process (each call after the first is a silent no-op) rather than erroring or panicking, since tracing::dispatcher::set_global_default can only succeed once – this keeps the function safe to call from tests that run multiple commands in the same process.

§Errors

Returns an error if the logging configuration itself is invalid (unparseable --log-level/--log-color) or the configured output can’t be opened.