Skip to content

Commit

Permalink
[10 of 10]: docs: explain use of lower case log level names
Browse files Browse the repository at this point in the history
Since our convention throughout the docs is to use the lower case
form of log level names (e.g., "info" rather than "INFO"), users
might mistakenly infer that we are implying that only the lower case
forms are legit. Careful readers might even suspect that the handful
of departures are typos rather than deliberate examples.

This change adds a blurblet to the README.md and to the top-level
API docs explaining the convention and the motivation for using
it (consistency).
  • Loading branch information
salewski committed Dec 6, 2020
1 parent b844d58 commit 5595a4d
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
5 changes: 5 additions & 0 deletions README.md
Expand Up @@ -57,6 +57,11 @@ $ RUST_LOG=INFO ./main
[2018-11-03T06:09:06Z INFO default] starting up
```

So which form should you use? For consistency, our convention is to use lower
case names. Where our docs do use other forms, they do so in the context of
specific examples, so you won't be surprised if you see similar usage in the
wild.

The log levels that may be specified correspond to the [`log::Level`][level-enum]
enum from the `log` crate. They are:

Expand Down
12 changes: 8 additions & 4 deletions src/lib.rs
Expand Up @@ -120,16 +120,19 @@
//! * `debug`
//! * `trace`
//!
//! The letter case is not significant for the logging level names; e.g.,
//! `debug`, `DEBUG`, and `dEbuG` all represent the same logging level.
//!
//! There is also a pseudo logging level, `off`, which may be specified to
//! disable all logging for a given module or for the entire application. As
//! with the logging levels, the letter case is not significant[^fn-off].
//!
//! [^fn-off]: Similar to the universe of log level names, the `off` pseudo
//! log level feature is also provided by the underlying `log` crate.
//!
//! The letter case is not significant for the logging level names; e.g.,
//! `debug`, `DEBUG`, and `dEbuG` all represent the same logging level. For
//! consistency, our convention is to use the lower case names. Where our docs
//! do use other forms, they do so in the context of specific examples, so you
//! won't be surprised if you see similar usage in the wild.
//!
//! As the log level for a module is optional, the module to enable logging for
//! is also optional. **If only a level is provided, then the global log
//! level for all modules is set to this value.**
Expand All @@ -146,7 +149,8 @@
//! * `hello,std::option` turns on hello, and std's option logging
//! * `error,hello=warn` turn on global error logging and also warn for hello
//! * `error,hello=off`` turn on global error logging, but turn off logging for hello
//! * `OFF` turns off all logging for the application
//! * `off` turns off all logging for the application
//! * `OFF` turns off all logging for the application (same as previous)
//!
//! ## Filtering results
//!
Expand Down

0 comments on commit 5595a4d

Please sign in to comment.