Skip to content

Commit

Permalink
WIP: DO NOT MERGE
Browse files Browse the repository at this point in the history
  • Loading branch information
abusalimov committed Sep 10, 2015
1 parent 8fc388e commit 3928caf
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -87,29 +87,29 @@ Inside tests it is possible to change the log level for the captured
log messages. This is supported by the ``caplog`` funcarg::

def test_foo(caplog):
caplog.setLevel(logging.INFO)
caplog.set_level(logging.INFO)
pass

By default the level is set on the handler used to catch the log
messages, however as a convenience it is also possible to set the log
level of any logger::

def test_foo(caplog):
caplog.setLevel(logging.CRITICAL, logger='root.baz')
caplog.set_level(logging.CRITICAL, logger='root.baz')
pass

It is also possible to use a context manager to temporarily change the
log level::

def test_bar(caplog):
with caplog.atLevel(logging.INFO):
with caplog.at_level(logging.INFO):
pass

Again, by default the level of the handler is affected but the level
of any logger can be changed instead with::

def test_bar(caplog):
with caplog.atLevel(logging.CRITICAL, logger='root.baz'):
with caplog.at_level(logging.CRITICAL, logger='root.baz'):
pass

Lastly all the logs sent to the logger during the test run are made
Expand Down

0 comments on commit 3928caf

Please sign in to comment.