0.5.5
Key Changes
- Allow toggling parts of the default format without having to write one from scratch
Contributions
More Details
Builder::default_format_*
The default format can be easily tweaked by conditionally enabling/disabling parts of it in the main Builder
. The API looks like:
impl Builder {
fn default_format(&mut self) -> &mut Self;
fn default_format_timestamp(&mut self, write: bool) -> &mut Self;
fn default_format_module_path(&mut self, write: bool) -> &mut Self;
fn default_format_level(&mut self, write: bool) -> &mut Self;
}
Calling default_format_*
will store whether or not we want to include those parts of the log, without affecting a custom format. That means:
Builder::new()
.format(|buf, record| { ... })
.default_format_timestamp(false)
.init();
Is the same as:
Builder::new()
.format(|buf, record| { ... })
.init();
Setting a custom format won't clobber any values passed to default_format_*
methods. That means:
Builder::new()
.default_format_timestamp(false)
.format(|buf, record| { ... })
.default_format()
.init();
Is the same as:
Builder::new()
.default_format_timestamp(false)
.init();
Builder::from_default_env
A new from_default_env
method that's a convenient way of calling from_env(env_logger::Env::default())
.