Skip to content

Commit

Permalink
Add cookbook section to docs
Browse files Browse the repository at this point in the history
  • Loading branch information
vmalloc committed Oct 11, 2016
1 parent 42aa39b commit f158adb
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
20 changes: 20 additions & 0 deletions docs/cookbook.rst
@@ -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')
1 change: 1 addition & 0 deletions docs/index.rst
Expand Up @@ -38,6 +38,7 @@ Documentation
api/index
designexplained
designdefense
cookbook
changelog

Project Information
Expand Down

0 comments on commit f158adb

Please sign in to comment.