init

Function init 

Source
pub fn init(
    filter: LevelFilter,
    modules: impl IntoIterator<Item = impl ToString>,
)
Expand description

Initializes the logger. This function spawns a thread to read log messages and write them to the appropriate output without blocking the current task.

This function also sets a custom panic hook to log panics. If you need to set a custom panic hook, set it after this function is called to prevent your custom hook from being overriden.

Once this function is called, you must avoid calling println! and eprintln!.

Arguments:

  • filter - The level filter for the logger.
  • modules - A list of root module names which to log. An empty array will log all modules. You may want to set this to your crate’s name, like ["my_crate_name"], to only display logs from your crate’s modules.

Example:

use log::LevelFilter;
 
// Displays all logs from all crates.
pretty_logging::init(LevelFilter::Trace, []);