11==============================
2- Flask Error Monitor
2+ Error Tracker
33==============================
44
5- Full featured error monitor app for Flask
5+ Full featured error tracking module for Python apps supports Flask and Django
66
7- .. image :: https://travis-ci.org/sonus21/flask- error-monitor .svg?branch=master
8- :target: https://travis-ci.org/sonus21/flask- error-monitor
7+ .. image :: https://travis-ci.org/sonus21/error-tracker .svg?branch=master
8+ :target: https://travis-ci.org/sonus21/error-tracker
99
10- .. image :: https://coveralls.io/repos/github/sonus21/flask- error-monitor /badge.svg
11- :target: https://coveralls.io/github/sonus21/flask- error-monitor
10+ .. image :: https://coveralls.io/repos/github/sonus21/error-tracker /badge.svg
11+ :target: https://coveralls.io/github/sonus21/error-tracker
1212
1313Introduction
1414------------
15+ ErrorTracker is a batteries-included app and extensions for python app, that can track errors, send notification, mask sensitive data and capture frames data.
1516
16- Flask-Error-Monitor is a batteries-included, simple-to-use `Flask <http://flask.pocoo.org/ >`_ extension that lets you
17- add error recording interfaces to Flask applications. It's implemented in such a way that the developer has total control of the resulting application.
17+ It plays nicely with `Django <https://www.djangoproject.com/ >`_ and `Flask <http://flask.pocoo.org/ >`_
1818
19- Out-of-the-box, Flask-Error-Monitor plays nicely with various ORM's, including
19+ Simple to use extension that lets you add error recording interfaces to Python applications.
20+ It's implemented in such a way that the developer has total control of the resulting application.
2021
21- - ` SQLAlchemy < http://www.sqlalchemy.org/ >`_,
22+ Out-of-the-box, Error Tracker plays nicely with various ORM's, including
2223
24+ - `SQLAlchemy <http://www.sqlalchemy.org/ >`_,
2325- `MongoEngine <http://mongoengine.org/ >`_,
26+ - `Django ORM <https://tutorial.djangogirls.org/en/django_orm/ >`_
2427
2528
2629It also boasts a simple Model management interface.
2730
28- The biggest feature of Flask-Error-Monitor is flexibility. To start off with you can create a very simple application in no time,
31+ The biggest feature of ErrorTracker is flexibility. To start off with you can create a very simple application in no time,
2932with exception monitor enabled, but then you can go further and customize different aspects.
3033
31- Flask-Error-Monitor is an active project, well-tested and production ready.
34+ ErrorTracker is an active project, well-tested and production ready.
3235
3336Installation
3437------------
35- To install Flask-Error-Monitor , simply::
38+ To install ErrorTracker , simply::
3639
37- git clone git@github.com:sonus21/flask-error-monitor.git
38- cd flask-error-monitor
39- python setup.py install
40+ pip install error-tracker
4041
4142
4243Features
43- -------------
44+ --------
4445- Sensitive data( like *password *, *secret * ) Masking
4546- Record all the frames ( frame data are stored in JSON format so that it can be analyzed later)
4647- Unique URL generation
4748- Number of times the exception occurred and first/last time of exception
48- - Sending emails with exception details
49+ - Sending notifications with exception details
4950- Record different types of exception like 500 or 404 etc
51+ - Raise or update ticket in Jira/Bugzilla etc by ticketing interface.
52+
53+ Usage
54+ -----
55+
56+ Flask App configuration
57+ =======================
58+
59+ .. code ::
60+
61+ ...
62+ APP_ERROR_SEND_EMAIL = True
63+ APP_ERROR_RECIPIENT_EMAIL = ('example@example.com',)
64+ APP_ERROR_SUBJECT_PREFIX = "Server Error"
65+ APP_ERROR_EMAIL_SENDER = 'user@example.com'
66+
67+
68+
69+ app.py
70+
71+ .. code ::
72+
73+ from flask import Flask
74+ from flask_mail import Mail
75+ import settings
76+ from error_tracker import AppErrorTracker, NotificationMixin
77+ from flask_sqlalchemy import SQLAlchemy
78+ ...
79+ app = Flask(__name__)
80+ app.config.from_object(settings)
81+ db = SQLAlchemy(app)
82+ class Notifier(Mail, NotificationMixin):
83+ def notify(self, request, exception,
84+ email_subject=None,
85+ email_body=None,
86+ from_email=None,
87+ recipient_list=None):
88+ message = Message(email_subject, recipient_list, email_body, sender=from_email)
89+ self.send(message)
90+ mailer = Notifier(app=app)
91+ error_tracker = AppErrorTracker(app=app, db=db, notifier=mailer)
92+
93+ ....
94+
95+ ....
96+ # Record exception when 404 error code is raised
97+ @app.errorhandler(403)
98+ def error_403(e):
99+ error_tracker.record_exception()
100+ # any custom logic
101+
102+ # Record error using decorator
103+ @app.errorhandler(500)
104+ @error_tracker.track_exception
105+ def error_500(e):
106+ # some custom logic
107+ ....
108+
109+
110+ Django App Usage
111+ ================
112+
113+ We need to update settings.py file as
114+
115+ - Add app to installed apps list
116+ - Add Middleware for exception tracking. This should be added at the end so that it can process exception 1st in the middleware call stack.
117+ - Other configs related to notification
118+
119+ Sample Code
120+
121+
122+ .. code ::
123+
124+ ...
125+ APP_ERROR_RECIPIENT_EMAIL = ('example@example.com',)
126+ APP_ERROR_SUBJECT_PREFIX = "Server Error"
127+ APP_ERROR_EMAIL_SENDER = 'user@example.com'
128+
129+ INSTALLED_APPS = [
130+ ...
131+ 'error_tracker.DjangoErrorTracker'
132+ ]
133+ MIDDLEWARE = [
134+ ...
135+ 'error_tracker.django.middleware.ExceptionTrackerMiddleWare'
136+ ]
137+
50138
51139 Documentations
52- -------------
53- This has got extensive document browse at https://flask- error-monitor .readthedocs.io/en/latest/
140+ --------------
141+ This has got extensive document browse at https://error-tracker .readthedocs.io/en/latest/
54142
55143All docs are in `docs/source `
56144
@@ -62,27 +150,36 @@ Examples
62150Several usage examples are included in the */tests * folder. Please feel free to add your own examples, or improve
63151on some of the existing ones, and then submit them via GitHub as a *pull-request *.
64152
65- You can see some of these examples in action at https://github.com/sonus21/flask- error-monitor /tree/master/examples.
153+ You can see some of these examples in action at https://github.com/sonus21/error-tracker /tree/master/examples
66154To run the examples on your local environment, one at a time, do something like::
67155
68- cd flask-error-monitor
69- python examples/simple/app.py
156+ cd error-tracker/examples
157+
158+
159+ Django::
160+
161+ cd error-tracker/examples
162+ cd DjangoSample
163+ python manage.py runserver
164+
165+ Flask::
166+
167+ cd flask-sample
168+ python app.py
70169
71170
72171Tests
73172-----
74- Test are run with *nose *. If you are not familiar with this package you can get some more info from `their website <https://nose.readthedocs.io/ >`_.
75-
76173To run the tests, from the project directory, simply::
77174
78175 pip install -r requirements-dev.txt
79- nosetests
176+ bash tests/run-tests.sh
80177
81178You should see output similar to::
82179
83180 .............................................
84181 ----------------------------------------------------------------------
85- Ran 26 tests in 1.144s
182+ Ran 29 tests in 1.144s
86183
87184 OK
88185
0 commit comments