Problem
Currently, all preprocessors need to call their own logging library. As calls to preprocessors are done within the main mdBook process, it would make sense to have a uniform logger across all preprocessors, so that when they log messages, it does not look weird compared to mdBook's own logging.
Proposed Solution
Move main::init_logger to utils::init_logger and make it public, so that people can opt in for the same logger as mdBook.
|
fn init_logger() { |
|
let mut builder = Builder::new(); |
|
|
|
builder.format(|formatter, record| { |
|
writeln!( |
|
formatter, |
|
"{} [{}] ({}): {}", |
|
Local::now().format("%Y-%m-%d %H:%M:%S"), |
|
record.level(), |
|
record.target(), |
|
record.args() |
|
) |
|
}); |
|
|
|
if let Ok(var) = env::var("RUST_LOG") { |
|
builder.parse_filters(&var); |
|
} else { |
|
// if no RUST_LOG provided, default to logging at the Info level |
|
builder.filter(None, LevelFilter::Info); |
|
// Filter extraneous html5ever not-implemented messages |
|
builder.filter(Some("html5ever"), LevelFilter::Error); |
|
} |
|
|
|
builder.init(); |
|
} |
Notes
No response
Problem
Currently, all preprocessors need to call their own logging library. As calls to preprocessors are done within the main mdBook process, it would make sense to have a uniform logger across all preprocessors, so that when they log messages, it does not look weird compared to mdBook's own logging.
Proposed Solution
Move
main::init_loggertoutils::init_loggerand make it public, so that people can opt in for the same logger as mdBook.mdBook/src/main.rs
Lines 97 to 121 in efb671a
Notes
No response