-
Notifications
You must be signed in to change notification settings - Fork 165
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
2 changed files
with
21 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
Cookbook | ||
======== | ||
|
||
Filtering Records Based on Extra Info | ||
------------------------------------- | ||
|
||
.. code-block:: python | ||
# This code demonstrates the usage of the `extra` argument for log records to enable advanced filtering of records through handlers | ||
import logbook | ||
if __name__ == "__main__": | ||
only_interesting = logbook.FileHandler('/tmp/interesting.log', filter=lambda r, h: r.extra['interesting']) | ||
everything = logbook.FileHandler('/tmp/all.log', bubble=True) | ||
with only_interesting, everything: | ||
logbook.info('this is interesting', extra={'interesting': True}) | ||
logbook.info('this is not interesting') |
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 |
---|---|---|
|
@@ -38,6 +38,7 @@ Documentation | |
api/index | ||
designexplained | ||
designdefense | ||
cookbook | ||
changelog | ||
|
||
Project Information | ||
|