Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/miso-belica/diagnostics
Alternative to Python's module `cgitb` with template inspired by http://nette.org/ and https://www.djangoproject.com/
https://github.com/miso-belica/diagnostics
debugger debugger-visualizer logging python sentry
Last synced: 4 months ago
JSON representation
Alternative to Python's module `cgitb` with template inspired by http://nette.org/ and https://www.djangoproject.com/
- Host: GitHub
- URL: https://github.com/miso-belica/diagnostics
- Owner: miso-belica
- License: other
- Created: 2013-02-09T22:07:46.000Z (almost 12 years ago)
- Default Branch: dev
- Last Pushed: 2017-03-04T13:30:21.000Z (almost 8 years ago)
- Last Synced: 2024-09-24T16:11:28.027Z (5 months ago)
- Topics: debugger, debugger-visualizer, logging, python, sentry
- Language: Python
- Homepage: https://pypi.python.org/pypi/diagnostics/
- Size: 61.5 KB
- Stars: 14
- Watchers: 4
- Forks: 2
- Open Issues: 3
-
Metadata Files:
- Readme: README.rst
- Changelog: CHANGELOG.rst
- License: LICENSE.rst
Awesome Lists containing this project
README
===========
Diagnostics
===========
.. image:: https://api.travis-ci.org/miso-belica/diagnostics.png?branch=master
:target: https://travis-ci.org/miso-belica/diagnosticsModule for logging of `detailed traceback
`_ as HTML page.
Unexpected exceptions are catched and logged for further audit. Exceptions
in diagnostic's exception handler are properly handled and logged
(but formatted only as standard Python traceback). Usage is simple as code below... code-block:: python
from diagnostics import exception_hook
if __name__ == '__main__':
# you have to create "log/" directory next to file that is your main module
exception_hook.enable().. code-block:: python
from diagnostics import exception_hook
from diagnostics.storages import FileStorageif __name__ == '__main__':
# or simply set your own storage
directory_path = "/path/to/your/log/directory/with/html/tracebacks"
exception_hook.enable(storage=FileStorage(directory_path)).. code-block:: python
from diagnostics import exception_hook
if __name__ == '__main__':
with exception_hook:
try_do_risky_job(...)There is even support for logging in diagnostics. Class
``diagnostics.logging.FileHandler`` creates files with detailed traceback
and log messages are appended to the file *info.log* in directory with
logged tracebacks... code-block:: python
import logging
from diagnostics import exception_hook
from diagnostics.logging import FileHandlerif __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").. code-block:: python
import logging
from diagnostics import exception_hook
from diagnostics.logging import FileHandlerif __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)Installation
------------
From PyPI
::pip install diagnostics
or from git repo
::pip install git+git://github.com/miso-belica/diagnostics.git
Tests
-----
Run tests via.. code-block:: bash
$ nosetests-2.6 && nosetests-3.2 && nosetests-2.7 && nosetests-3.3