Key-value logger for Rust

Usage
Like other loggers, kvlogger must be initialized and registered as the default log handler in your program. You can then use either that usual log macros (that do not handle key/value pairs), or use the kvlog! macro and add your data.
Any type that implements Display can be used as a value.
use Error;
use *;
use ;
Configuration
kvlogger uses env_logger under the hood for filter selection. You have two ways to configure the desired level for your logs:
- You can force the logger at a specific level with the
set_level(mut self, log::Level)method ofKvLoggerBuilder:
default
.set_level
.init?;
- Otherwise, you can use the
RUST_LOGenvironment variable to specify which logs should be considered. See the env_logger documentation for more information.
$ RUST_LOG=rocket=error,main=info cargo run
- If using the
datetimefeature (see below), you can specify another format from the default, with theset_datetime_format(mut self, Into<String>)method:
default
.set_datetime_format
.init?;
Optional features
By default, the date used is printed as the number of seconds since UNIX epoch. You can opt in the use of more complex (and human readable) formats by enabling the datetime feature in Cargo.toml:
[]
= { = "*", = ["datetime"] }
Examples
$ cargo run --example simple
$ cargo run --example simple --features datetime
$ RUST_LOG=simple=trace cargo run --example simple --features datetime