Expand description
A pretty, opinionated style for env_logger inspirated by pretty-env-logger.
It is not a goal of this crate to create a feature rich wrapper around env_logger.
Instead it does provide a formater, which can be applied to the env_logger::Builder
.
Additional an optional function to create and register a zero config logger is provided.
Timestamp, emojis and modules can be disable separately.
§Preview
with timestamps:
§Usage
§Quickstart
my_env_logger_style::just_log();
info!("Hello, world!");
This creates the default env_logger from environment variables and register it as logger.
§Advance
You can also create an env_logger::Builder
and apply the style definded at this crate,
by using the format()
function.
use log::info;
use my_env_logger_style::format;
env_logger::Builder::new()
.parse_default_env()
.format(format)
.init();
info!("Hello, world!");
§Feature-flags
§time (default)
Enable RFC3339 timestamps
§custom-arg-formatter
Allow using a custom formater to format the args (the actual message) of the log record. As example this can be used to avoid logging private userdata.
Re-exports§
pub use env_logger;
Enums§
- Timestamp
Precision - RFC3339 timestamps
Traits§
Functions§
- builder
- Create a preconfigured builder,
with same configuration like
just_log()
. - format
- log formater witch can be used at the
format()
function of theenv_logger::Builder
. - get_
set_ max_ module_ len - return the current module len and set the module length to the maximum of the current value and the given
len
. - just_
log - create and regstier a logger from the default environment variables
- set_
arg_ formatter custom-arg-formatter
- Use a custom formater to format the args (the actual message) of the record . This function can only be called once and return an Error if called a second time.
- set_
timestamp_ precision time
- set the timestamp precision or disable timestamps complete
- show_
emoji - enable or disabel showing emojis before the log level
- show_
module - enable or disabel showing the module path