Expand description
A filter that follows the famous RUST_LOG directive pattern.
Log levels are controlled on a per-module basis, and by default all logging is disabled except
for the error level.
You can use RustLogFilterBuilder::from_default_env to configure the filter from the
RUST_LOG environment variable, or RustLogFilterBuilder::from_spec to configure the
filter by directly passing a specification string.
The specification string is a comma-separated list of logging directives. A logging directive is of the form:
target=leveltarget is typically path::to::module, but it may also be set manually via the log macros.
The path to the module is rooted in the name of the crate it was compiled for. Thus, if your
program is contained in a file hello.rs, for example, to turn on logging for this file you
would use a value of RUST_LOG=hello. Furthermore, this path is a prefix-search, so all modules
nested in the specified module will also have logging enabled.
When providing the crate name or a module path, explicitly specifying the log level is optional. If omitted, all logging for the item (and its children) will be enabled.
The names of the log levels that may be specified correspond to the variations of the Level
enum. The most common used levels include:
fatalerrorwarninfodebugtrace
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; e.g., debug, DEBUG, and dEbuG all represent the same logging level.
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.
Some examples of valid values are:
helloturns on all logging for the ‘hello’ moduletraceturns on all logging for the application, regardless of its nameTRACEturns on all logging for the application, regardless of its name (same as previous)infoturns on all info loggingINFOturns on all info logging (same as previous)hello=debugturns on debug logging for ‘hello’hello=DEBUGturns on debug logging for ‘hello’ (same as previous)hello,std::optionturns on hello, and std’s option loggingerror,hello=warnturns on global error logging and also warn for helloerror,hello=offturns on global error logging, but turn off logging for hellooffturns off all logging for the applicationOFFturns off all logging for the application (same as previous)
Structs§
- Rust
LogFilter - A filter consists of one or more comma-separated directives which match on
Record. - Rust
LogFilter Builder - A builder for
RustLogFilter.
Constants§
- DEFAULT_
FILTER_ ENV - The default environment variable for filtering logs.