Skip to content

Commit 88e583e

Browse files
committed
Tidy up README
1 parent a3ae008 commit 88e583e

File tree

1 file changed

+20
-16
lines changed

1 file changed

+20
-16
lines changed

README.md

+20-16
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# simple_logger [![](https://img.shields.io/github/tag/borntyping/rust-simple_logger.svg)](https://github.com/borntyping/rust-simple_logger/tags) [![](https://img.shields.io/travis/borntyping/rust-simple_logger.svg)](https://travis-ci.org/borntyping/rust-simple_logger) [![](https://img.shields.io/github/issues/borntyping/rust-simple_logger.svg)](https://github.com/borntyping/rust-simple_logger/issues)
1+
# simple_logger [![](https://img.shields.io/github/tag/borntyping/rust-simple_logger.svg)](https://github.com/borntyping/rust-simple_logger/tags)
22

33
A logger that prints all messages with a readable output format.
44

@@ -38,6 +38,8 @@ You can run the above example with:
3838
cargo run --example init
3939
```
4040

41+
### Optional features
42+
4143
The `colors` and `timestamps` features are enabled by default. You can remove these
4244
features and their respective dependencies by disabling all features in your
4345
`Cargo.toml`.
@@ -84,26 +86,28 @@ Multiple features can be combined.
8486
features = ["colors", "threads", "timestamps", "nightly", "stderr"]
8587
```
8688

87-
Wrapping with another logger
88-
----------------------------
89+
### Wrapping with another logger
8990

90-
Users that might want to wrap this logger to be able to catch log events for various
91-
reasons can setup the logger as follows:
91+
You might want to wrap this logger to do your own processing before handing events to a SimpleLogger instance. Instead
92+
of calling `init()` which calls `log::set_max_level` and `log::set_boxed_logger`, you can call those functions directly
93+
giving you the chance to wrap or adjust the logger. See [wrap.rs](examples/wrap.rs) for a more detailed example.
9294

93-
On windows machines:
94-
```rust
95-
let logger = SimpleLogger::new();
96-
set_up_color_terminal();
97-
let max_level = logger.max_level();
98-
```
95+
The call to `set_up_color_terminal()` is currently only needed on Windows when the `colored` feature is enabled. If
96+
you're not on Windows and not using the `colored` feature, it will do nothing.
9997

100-
Otherwise:
10198
```rust
102-
let logger = SimpleLogger::new();
103-
let max_level = logger.max_level();
104-
```
99+
use simple_logger::{SimpleLogger, set_up_color_terminal};
105100

106-
The user can then themselves call `log::set_max_level` and `log::set_boxed_logger` or equivalent as they wish.
101+
fn main() {
102+
set_up_color_terminal();
103+
104+
let logger = SimpleLogger::new();
105+
let max_level = logger.max_level();
106+
107+
log::set_max_level(max_level);
108+
log::set_boxed_logger(Box::new(logger)).unwrap();
109+
}
110+
```
107111

108112
Licence
109113
-------

0 commit comments

Comments
 (0)