Skip to content

This is a handler for the python standard logging framework that can be used to tell whether messages have been logged at or above a certain level.

Notifications You must be signed in to change notification settings

simplistix/errorhandler

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

46 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Travis Coveralls Docs PyPI

ErrorHandler

This is a handler for the python standard logging framework that can be used to tell whether messages have been logged at or above a certain level.

This can be useful when wanting to ensure that no errors have been logged before committing data back to a database.

As an example, first, you set up the error handler:

>>> from errorhandler import ErrorHandler
>>> e = ErrorHandler()

Then you can log and check the handler at any point to see if it has been triggered:

>>> e.fired
False
>>> from logging import getLogger
>>> logger = getLogger()
>>> logger.error('an error')
>>> e.fired
True

You can use the fired attribute to only perform actions when no errors have been logged:

>>> if e.fired:
...   print "Not updating files as errors have occurred"
Not updating files as errors have occurred

Installation

Do the following in your virtualenv:

pip install errorhandler

Documentation

The latest documentation can also be found at: http://errorhandler.readthedocs.org/en/latest/

Licensing

Copyright (c) 2008-2015 Simplistix Ltd, 2016 Chris Withers. See docs/license.txt for details.

About

This is a handler for the python standard logging framework that can be used to tell whether messages have been logged at or above a certain level.

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages