Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
14 changed files
with
309 additions
and
70 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
# Initialization | ||
|
||
To customize logging formats and levels, `minilog` supports the same initialization arguments as [`logging.basicConfig`](https://docs.python.org/3/library/logging.html#logging.basicConfig). To set the format for all logging handlers: | ||
|
||
```python | ||
log.init(format="%(levelname)s: %(name)s: %(message)s") | ||
``` | ||
|
||
To set the level for the root logging handler: | ||
|
||
```python | ||
log.init(format=<…>, level=log.WARNING) | ||
``` | ||
|
||
### Debug Option | ||
|
||
To simply enable debug-level logging, a convenience option is provided: | ||
|
||
```python | ||
log.init(format=<…>, debug=True) | ||
``` | ||
|
||
### Verbosity Option | ||
|
||
To work with frameworks that provide a `verbosity` level in their CLI frameworks (such as [Django](https://docs.djangoproject.com/en/2.1/ref/django-admin/#cmdoption-verbosity)), that can be used instead: | ||
|
||
```python | ||
log.init(format=<…>, verbosity=verbosity) | ||
``` | ||
|
||
### Silencing Loggers | ||
|
||
To set the logging level for specific named loggers: | ||
|
||
```python | ||
log.silence('selenium') | ||
log.silence('werkzeug', 'requests', allow_warning=True) | ||
``` | ||
|
||
### Reset Loggers | ||
|
||
Finally, if another package has already set the logging format or level, that can be reset so that `minilog` takes over: | ||
|
||
```python | ||
log.init(…, reset=True) | ||
``` | ||
|
||
# Records | ||
|
||
In addition to the standard [`LogRecord`](https://docs.python.org/3/library/logging.html#logrecord-attributes) attributes, the following additional patterns are available: | ||
|
||
| Logging Format | Description | ||
| --- | --- | | ||
| `%(relpath)s` | Full pathname of the source file where the logging call was issued relative to the current working directory. | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.