pub fn initialize_with_formatter(filename_prefix: &str, formatter: FormatFn)
Expand description

Initializes the current process/thread with a logger, parsing the RUST_LOG environment variables to set the logging level filter and/or directives to set a filter by module name, following the usual env_logger conventions. The format function specifies the format in which the logs will be printed.

Must be called on every running thread, or else logging will panic the first time it’s used.

use file_per_thread_logger::{initialize_with_formatter, FormatFn};
use std::io::Write;

let formatter: FormatFn = |writer, record| {
    writeln!(
        writer,
        "{} [{}:{}] {}",
        record.level(),
        record.file().unwrap_or_default(),
        record.line().unwrap_or_default(),
        record.args()
    )
};
initialize_with_formatter("log-file-prefix", formatter);