Softpedia
 


LINUX CATEGORIES:



GLOBAL PAGES >>
NEWS ARCHIVE >>
SOFTPEDIA REVIEWS >>
MEET THE EDITORS >>
WEEK'S BEST
  • Linux Kernel 3.9.6 / 3....
  • Linux Kernel 3.0.82 LTS...
  • KDE Software Compilatio...
  • PulseAudio 4.0
  • Wireshark 1.10.0
  • NetworkManager 0.9.8.2
  • LibreOffice 3.6.6 / 4.0...
  • SystemRescueCd 3.7.0
  • Linux Kernel 3.10 RC6
  • Ubuntu Tweak 0.8.5
  • Home > Linux > Internet > HTTP (WWW)

    errornot_notifier 0.1.0

    Download button

    No screenshots available
    Downloads: 221  View global page NEW!  Tell us about an update
    User Rating:
    Rated by:
    NOT RATED
    0 user(s)
    Developer:

    License / Price:

    Last Updated:

    Category:
    Pierre Ruyssen | More programs
    AGPL / FREE
    March 13th, 2010, 00:09 GMT
    ROOT / Internet / HTTP (WWW)

     Read user reviews (0)  Refer to a friend  Subscribe

    errornot_notifier description

    Python ErrorNot Notifier

    errornot_notifier comes in two flavors:

     * a WSGI application,
     * a logging handler.

    The configuration

    However you decide to use Python ErrorNot notifier, you should set some variables first:

    from errornot import notifier

    notifier.API_KEY = "900b7e06850c9864f908469c"
    notifier.HOST = "localhost:3000"
    notifier.API_VERSION = "0.1.0"


    The WSGI ErrorNot notifier

    You can use the ErrorNot as a WSGI application. You just have to insert it somewhere in your applications stack (as low as possible, if you want to catch all your exceptions). The WSGI notifier will send some info about the request and the environment to ErrorNot. This is recommended way of using ErrorNot notifier in a WSGI web app.

    Exemple of a very simple "Hello World" application:

    def hello_world(environ, start_response):
     """Very simple WSGI app saying hello.
     """
     start_response('200 OK', [('Content-Type', 'text/html')])
     return ['''< title >Hello %(subject)s< /title >
     < p >Hello World!< /p >''']

    def not_found(environ, start_response):
     """Called if no URL matches."""
     start_response('404 NOT FOUND', [('Content-Type', 'text/plain')])
     return ['Not Found']

    def routing(environ, start_response):
     path = environ.get('PATH_INFO', '').lstrip('/')
     if path == "hello":
     return hello_world(environ, start_response)
     if path == "error":
     raise AssertionError("error msg")
     return not_found(environ, start_response)

    from wsgiref.simple_server import make_server
    from errornot import wsgi_notifier

    errornot_notifier = wsgi_notifier.WSGINotifier(routing)
    srv = make_server('localhost', 8080, errornot_notifier)
    srv.serve_forever()


    The above application will raise an error if you visit http://localhost:8080/error, and post an error msg to the ErrorNot server you have configured first.

    The logging handler

    The ErrorNot notifier also has a logger handler, because it might be usefull to use it in a non WSGI application, or to manually trigger errors posting. If you are new to logging facilities in Python, please read http:docs.python.org/library/logging.html.

    To use it that way, just bing the handler to one of your loggers, and start logging exceptions. ErrorNot being intended to log errors, the notifier will look in the stack for exceptions and will grab informations about the last raised. As so, it is recommended to use inside except blocks only.

    import logging

    logging.basicConfig()
    logger = logging.getLogger('test')
    logger.setLevel(logging.ERROR)
    logger.addHandler(notifier.ErrorNotHandler())

    # This will post an error:
    try:
     raise AssertionError("Evil error")
    except Exception, e:
     logger.exception(e)


    Have fun!


    Product's homepage

    Requirements:

    · Python

      


    TAGS:

    ErrorNot notifier | errors agregator | WSGI logging | ErrorNot | notifier | agregator

    Go to top

    WindowsGamesDriversMacLinuxScriptsMobileHandheldNews

    SUBMIT PROGRAM   |   ADVERTISE   |   GET HELP   |   SEND US FEEDBACK   |   RSS FEEDS   |   UPDATE YOUR SOFTWARE   |   ROMANIAN FORUM