- Notifications
You must be signed in to change notification settings - Fork2
Alternative to Python's module `cgitb` with template inspired byhttp://nette.org/ andhttps://www.djangoproject.com/
License
miso-belica/diagnostics
Folders and files
| Name | Name | Last commit message | Last commit date | |
|---|---|---|---|---|
Repository files navigation

Module for logging ofdetailed traceback as HTML page.Unexpected exceptions are catched and logged for further audit. Exceptionsin diagnostic's exception handler are properly handled and logged(but formatted only as standard Python traceback). Usage is simple as code below.
fromdiagnosticsimportexception_hookif__name__=='__main__':# you have to create "log/" directory next to file that is your main moduleexception_hook.enable()
fromdiagnosticsimportexception_hookfromdiagnostics.storagesimportFileStorageif__name__=='__main__':# or simply set your own storagedirectory_path="/path/to/your/log/directory/with/html/tracebacks"exception_hook.enable(storage=FileStorage(directory_path))
fromdiagnosticsimportexception_hookif__name__=='__main__':withexception_hook:try_do_risky_job(...)
There is even support for logging in diagnostics. Classdiagnostics.logging.FileHandler creates files with detailed tracebackand log messages are appended to the fileinfo.log in directory withlogged tracebacks.
importloggingfromdiagnosticsimportexception_hookfromdiagnostics.loggingimportFileHandlerif__name__=='__main__':file_path="/path/to/log/directory/with/html/tracebacks/info.log"log_handler=FileHandler(file_path)exception_hook.enable_for_logger(logging.getLogger(),handler=log_handler)try:try_do_risky_job(...)except:logging.exception("Risky job failed")
importloggingfromdiagnosticsimportexception_hookfromdiagnostics.loggingimportFileHandlerif__name__=='__main__':file_path="/path/to/log/directory/with/html/tracebacks/info.log"log_handler=FileHandler(file_path)exception_hook.enable_for_logger("example_logger",handler=log_handler)try:try_do_risky_job(...)except:logger=logging.getLogger("example_logger")logger.error("Error occured",exc_info=True)
From PyPI
pip install diagnostics
or from git repo
pip install git+git://github.com/miso-belica/diagnostics.git
Run tests via
$ nosetests-2.6&& nosetests-3.2&& nosetests-2.7&& nosetests-3.3
About
Alternative to Python's module `cgitb` with template inspired byhttp://nette.org/ andhttps://www.djangoproject.com/
Topics
Resources
License
Uh oh!
There was an error while loading.Please reload this page.
Stars
Watchers
Forks
Packages0
Uh oh!
There was an error while loading.Please reload this page.