Expand description
json_env_logger is an extension of env_logger crate providing JSON formatted logs.
The env_logger is a crate that provides a way to declare what log levels are enabled for which modules \via a RUST_LOG env variable. See its documentation for
syntax of declaring crate and module filtering options.
§features
iso-timestamps
By default, a timestamp field called ts is emitted with the current unix epic timestamp in seconds
You can replace this with IOS-8601 timestamps by enabling the iso-timestamps feature. Note, this will add chrono crate
to your dependency tree.
[dependencies]
json_env_logger = { version = "0.1", features = ["iso-timestamps"] }backtrace
When registering a panic hook with panic_hook by default backtraces are omitted. You can
annotate your error with then by enabling the backtrace feature.
[dependencies]
json_env_logger = { version = "0.1", features = ["backtrace"] }Functions§
- builder
- Yields the standard
env_logger::Builderconfigured to log in JSON format - init
- Register configured json env logger implementation with
logcrate. - panic_
hook - Register a panic hook that serializes panic information as json
and logs via
log::error - try_
init - Register configured json env logger with
logcrate