Skip to content

Commit d4a1434

Browse files
authored
Rework the default format (#82)
* adjust the default format * remove FromStr impl for Color * note the stability of default format * make shim termcolor cargo test friendly * catch attempts to re-use builders
1 parent 15ed5c7 commit d4a1434

File tree

12 files changed

+564
-507
lines changed

12 files changed

+564
-507
lines changed

Cargo.toml

+1-4
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,6 @@ variable.
1313
categories = ["development-tools::debugging"]
1414
keywords = ["logging", "log", "logger"]
1515

16-
[maintenance]
17-
status = "actively-developed"
18-
1916
[workspace]
2017
members = [
2118
"ci"
@@ -37,4 +34,4 @@ name = "log-in-log"
3734
harness = false
3835

3936
[features]
40-
default = ["termcolor", "atty", "humantime", "regex"]
37+
default = ["termcolor", "atty", "humantime", "regex"]

README.md

+14-8
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ environment variable that corresponds with the log messages you want to show.
4040

4141
```bash
4242
$ RUST_LOG=info ./main
43-
INFO: 2017-11-09T02:12:24Z: main: starting up
43+
[2018-11-03T06:09:06Z INFO default] starting up
4444
```
4545

4646
### In tests
@@ -52,7 +52,7 @@ Tests can use the `env_logger` crate to see log messages generated during that t
5252
log = "0.4.0"
5353

5454
[dev-dependencies]
55-
env_logger = "0.5.13"
55+
env_logger = { version = "0.5.13", default-features = false }
5656
```
5757

5858
```rust
@@ -93,11 +93,11 @@ $ RUST_LOG=my_lib=info cargo test
9393
Running target/debug/my_lib-...
9494

9595
running 2 tests
96-
INFO: 2017-11-09T02:12:24Z: my_lib::tests: logging from another test
97-
INFO: 2017-11-09T02:12:24Z: my_lib: add_one called with -8
96+
[2017-11-09T02:12:24Z INFO my_lib::tests] logging from another test
97+
[2017-11-09T02:12:24Z INFO my_lib] add_one called with -8
9898
test tests::it_handles_negative_numbers ... ok
99-
INFO: 2017-11-09T02:12:24Z: my_lib::tests: can log from the test too
100-
INFO: 2017-11-09T02:12:24Z: my_lib: add_one called with 2
99+
[2017-11-09T02:12:24Z INFO my_lib::tests] can log from the test too
100+
[2017-11-09T02:12:24Z INFO my_lib] add_one called with 2
101101
test tests::it_adds_one ... ok
102102

103103
test result: ok. 2 passed; 0 failed; 0 ignored; 0 measured
@@ -115,8 +115,8 @@ $ RUST_LOG=my_lib=info cargo test it_adds_one
115115
Running target/debug/my_lib-...
116116

117117
running 1 test
118-
INFO: 2017-11-09T02:12:24Z: my_lib::tests: can log from the test too
119-
INFO: 2017-11-09T02:12:24Z: my_lib: add_one called with 2
118+
[2017-11-09T02:12:24Z INFO my_lib::tests] can log from the test too
119+
[2017-11-09T02:12:24Z INFO my_lib] add_one called with 2
120120
test tests::it_adds_one ... ok
121121

122122
test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured
@@ -138,3 +138,9 @@ if env::var("RUST_LOG").is_ok() {
138138
}
139139
builder.init();
140140
```
141+
142+
## Stability of the default format
143+
144+
The default format won't optimise for long-term stability, and explicitly makes no guarantees about the stability of its output across major, minor or patch version bumps during `0.x`.
145+
146+
If you want to capture or interpret the output of `env_logger` programmatically then you should use a custom format.

src/fmt/humantime/extern_impl.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ use humantime::{format_rfc3339_nanos, format_rfc3339_seconds};
55

66
use ::fmt::Formatter;
77

8-
pub(in ::fmt) mod pub_use_in_super {
8+
pub(in ::fmt) mod glob {
99
pub use super::*;
1010
}
1111

src/fmt/humantime/shim_impl.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,6 @@
22
Timestamps aren't available when we don't have a `humantime` dependency.
33
*/
44

5-
pub(in ::fmt) mod pub_use_in_super {
5+
pub(in ::fmt) mod glob {
66

77
}

0 commit comments

Comments
 (0)