Skip to content

Commit ed14486

Browse files
committed
Uniformly set default log level to INFO
Commit a98f548 ("Capture INFO and WARN from tracing by default") adjusted the tracing part of the crate to use the INFO log level by default. With this change we switch the log part over to doing the same.
1 parent c91596c commit ed14486

File tree

3 files changed

+20
-15
lines changed

3 files changed

+20
-15
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
Unreleased
2+
----------
3+
- Changed default log level to `INFO`
4+
5+
16
0.2.16
27
------
38
- Use `tracing-subscriber`'s `tracing-log` feature to unify log output

README.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -102,10 +102,11 @@ $ cargo test -- --nocapture
102102
```
103103

104104
Furthermore, the `RUST_LOG` environment variable is honored and can be
105-
used to influence the log level to work with (among other things).
106-
Please refer to the [`env_logger` docs][env-docs-rs] and
105+
used to influence the log level to work with (among other things). By
106+
default, log messages of criticality `INFO` (and higher) will be
107+
emitted. Please refer to the [`env_logger` docs][env-docs-rs] and
107108
[`tracing-subscriber`][tracing-env-docs-rs] documentation for supported
108-
syntax and more information.
109+
variable syntax and more information.
109110

110111
If the `trace` feature is enabled, the `RUST_LOG_SPAN_EVENTS`
111112
environment variable can be used to configure the tracing subscriber to

macros/src/lib.rs

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -155,21 +155,20 @@ impl AttributeArgs {
155155
/// Expand the initialization code for the `log` crate.
156156
#[cfg(all(feature = "log", not(feature = "trace")))]
157157
fn expand_logging_init(attribute_args: &AttributeArgs) -> Tokens {
158-
let add_default_log_filter = if let Some(default_log_filter) = &attribute_args.default_log_filter
159-
{
160-
quote! {
161-
let env_logger_builder = env_logger_builder
162-
.parse_env(::test_log::env_logger::Env::default().default_filter_or(#default_log_filter));
163-
}
164-
} else {
165-
quote! {}
166-
};
158+
let default_filter = attribute_args
159+
.default_log_filter
160+
.as_ref()
161+
.unwrap_or(&::std::borrow::Cow::Borrowed("info"));
167162

168163
quote! {
169164
{
170-
let mut env_logger_builder = ::test_log::env_logger::builder();
171-
#add_default_log_filter
172-
let _ = env_logger_builder.is_test(true).try_init();
165+
let _result = ::test_log::env_logger::builder()
166+
.parse_env(
167+
::test_log::env_logger::Env::default()
168+
.default_filter_or(#default_filter)
169+
)
170+
.is_test(true)
171+
.try_init();
173172
}
174173
}
175174
}

0 commit comments

Comments
 (0)