Is there any python exception notifier present?

638 Views Asked by At

What is my requirement ?

--> I need Exception notifier which will email to some specific configured user, about any sort of exception occurring in plain python app and web.py.

I want something similar to this http://matharvard.ca/posts/2011/jul/31/exception-notification-for-rails-3/

Is there anything same sort present ??

Please reply asap. Thanks.

4

There are 4 best solutions below

0
On

You can overwrite the excepthook function from the sys module, and handle any uncought exceptions there.

0
On

You can get what you want by:

  • Wrapping your code in try..except clause.
  • Using logging module to log the exceptions with a certain level of severity e.g ERROR.
  • Setting an SMTPHandler for exceptions of and above certain level.

This way is quite flexible. Your messages can be send to several places (like log files) and you can reconfigure your settings easily.

0
On

I have the same requirement with you. I write a simple module to mail uncaught exceptions to the developers, as well as to record them to log files. It is used in our teams' cron scripts written in Python. Hope it can be useful for you too.

0
On

If you are not using any python heavy weight framework, try: https://github.com/fossilet/exception-notifier , it seems to be similar to the Rails' Exception notification, but quite simple.

If you are using django, seems you can use its built-in feature:https://docs.djangoproject.com/en/dev/howto/error-reporting/ ( and also see this: https://github.com/pinax/django-notification)

If using tornado, try this: https://github.com/kanevski/tornadotoad this is the most similar solution in python comparing to rails. )