Expand description

filtering

Use the ENV variable RUST_LOG with module_name=level

RUST_LOG="tokio=warn,my_module=info,my_module::inner=trace"

A default level can be provided with just level. e.g. RUST_LOG=trace will enable trace for all modules.

You can disable specific modules/crates by using the off level

optional features

  • time allows formatting a UTC timestamp with the time crate.
    • see the formatting description here time: https://docs.rs/time

Modules

Configuration for various loggers

Structs

Color configuration for the logger

std::io::Write based logger, intended for std::fs::File

A multi-logger

Configuration for the logger

Stdout logger which supports colors

Enums

The set of available colors for the terminal foreground/background.

An error returned by the logger initialization

Logger line breaking style

How the timestamp should be displayed

Functions

Initialize the logger

Convenience function to create a terminal logger that uses a single-line output, and unix timestamps.

Convenience function to create a default terminal logger