@@ -52,7 +52,7 @@ Recording exception/error
5252An error/exception can be recorded using decorator or function call.
5353
5454- To record the error using decorator, decorate a function with :code: `track_exception ` or :code: `auto_track_exception `
55- - Where as to record error using function call use :code: `record_exception ` function.
55+ - Where as to record error using function call use :code: `capture_exception ` function.
5656- Exception detail can be written to a file, console or logger etc call method :code: `print_exception `
5757
5858All the data will be stored in the configured data store and these data will be available at configure URL path.
@@ -64,6 +64,12 @@ An instance of :code:`AppErrorTracker` needs to be created and have to be config
6464Monitoring feature can be configured either using object based configuration or app-based configuration,
6565the only important thing here is we should have all the required key configs in the app.config otherwise it will fail.
6666
67+ .. note ::
68+ Exception listing page is disabled by default. You need to enable that using view_permission parameter.
69+ view_permission function/callable class must return True/False based on the current request detail.
70+ This method would be called as view_permission(request).
71+
72+
6773For object based configuration add
6874**settings.py **
6975
@@ -97,15 +103,22 @@ For object based configuration add
97103 message = Message(email_subject, recipient_list, email_body, sender=from_email)
98104 self.send(message)
99105 mailer = Notifier(app=app)
100- error_tracker = AppErrorTracker(app=app, db=db, notifier=mailer)
106+
107+ # enable for all users
108+ class ViewPermission(ViewPermissionMixin):
109+ def __call__(self, request):
110+ return True
111+
112+ error_tracker = AppErrorTracker(app=app, db=db, notifier=mailer, view_permission=ViewPermission())
113+
101114
102115 ....
103116
104117 ....
105118 # Record exception when 404 error code is raised
106119 @app.errorhandler(403)
107120 def error_403(e):
108- error_tracker.record_exception ()
121+ error_tracker.capture_exception ()
109122 # any custom logic
110123
111124 # Record error using decorator
@@ -131,12 +144,19 @@ We need to update settings.py file as
131144
132145.. [1 ] This should be added at the end so that it can process exception 1st in the middleware call stack.
133146
147+ .. note ::
148+ Exception listing page is only enable for admin by default.
149+ You can enable for others by providing a custom implementation of ViewPermissionMixin.
150+ This class must return True/False based on the current request, False means not authorized, True means authorized.
151+
134152.. code ::
135153
136154 ...
137155 APP_ERROR_RECIPIENT_EMAIL = ('example@example.com',)
138156 APP_ERROR_SUBJECT_PREFIX = "Server Error"
139157 APP_ERROR_EMAIL_SENDER = 'user@example.com'
158+ # optional setting otherwise it's enabled for admin only
159+ APP_ERROR_VIEW_PERMISSION = 'permission.ErrorViewPermission'
140160
141161 INSTALLED_APPS = [
142162 ...
@@ -168,14 +188,14 @@ For example, if we want to use Flask then do
168188 * Create Flask App instance
169189 * Create Error Tracker app instance
170190 * DO NOT call run method of Flask app instance
171- * To track exception call :code: `error_tracker.record_exception ` method
191+ * To track exception call :code: `capture_exception ` method
172192
173193- Django App
174194 * Create Django App with settings and all configuration
175195 * Set environment variable **DJANGO_SETTINGS_MODULE **
176196 * call :code: `django.setup() `
177- * :code: `from error_tracker.django.middleware import error_tracker `
178- * To track exception do :code: `error_tracker.record_exception (None, exception) `
197+ * :code: `from error_tracker import error_tracker `
198+ * To track exception do :code: `capture_exception (None, exception) `
179199
180200
181201
0 commit comments