Logging
This logger implementation has been designed to be fast. It delegates most of the heavy work to a dedicated thread. It offers nice filtering capability that can be combined with an optional and easy to use TOML configuration.
Examples
To have a generale view of the capability of this crate, you can run this command:
or
Additional examples can be found here as well.
CLI Support
This logging factory handles the environnement variable RUST_LOG as well so it can be used like this (the logger has to be registered):
RUST_LOG="debug"
Building a logger
Here is an example of how to simply build a logger with the Debug
log verbosity level:
// Optionally you can specify your custom timestamp format
.timestamp_format
.set_level_from_str
.build
.expect;
debug!;
new
Filtering
Filtering out every log from dependencies and putting back in everything related to a particular target
is easy:
let toml = r#"
[logger]
level = "debug"
[[logger.rules]]
pattern = ".*"
exclude = true
[[logger.rules]]
pattern = "^holochain"
exclude = false
"#;
from_toml
.expect
.build
.expect;
// Should NOT be logged
debug!;
// Should be logged each in different color. We avoid filtering by prefixing using the 'target'
// argument.
info!;
info!;