Skip to content

Commit d67d89b

Browse files
committed
README: add intro regarding per-module logging
1 parent bed3a73 commit d67d89b

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

README.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,23 @@ $ RUST_LOG=info ./main
4747
[2018-11-03T06:09:06Z INFO default] starting up
4848
```
4949

50+
To set the log level on a per module basis, module names can be declared as `path::to::module=level` in **`RUST_LOG`**.
51+
52+
```console
53+
$ RUST_LOG=main=info ./main
54+
[2017-11-09T02:12:24Z ERROR main] this is printed by default
55+
[2017-11-09T02:12:24Z INFO main] the answer was: 12
56+
```
57+
58+
When dealing with crate name with hyphens, either the original form (e.g., `my-app`) or the canonical form (e.g., `my_app`) works.
59+
60+
```console
61+
$ RUST_LOG=my-app ./my-app # `RUST_LOG=my_app ./my-app` also works
62+
[2017-11-09T02:12:24Z DEBUG my_app] this is a debug message
63+
[2017-11-09T02:12:24Z ERROR my_app] this is printed by default
64+
[2017-11-09T02:12:24Z INFO my_app] the answer was: 12
65+
```
66+
5067
The letter case is not significant for the logging level names; e.g., `debug`,
5168
`DEBUG`, and `dEbuG` all represent the same logging level. Therefore, the
5269
previous example could also have been written this way, specifying the log

0 commit comments

Comments
 (0)