Jaktivity is a django app to log activity on a django powered website.
- Django 1.3+
jaktivityon your python path
INSTALLED_APPSin your settings
- syncdb (or run migrations if you are using south)
MIDDLEWARE_CLASSESin your settings
Adding a web view for the activity logs
jaktivityto your urls patterns += ('', (r'^activity/', include('jaktivity.urls', namespace='jaktivity')),) Sample templates are available in the sample_templates directory.
What gets logged
For HTTP requests that are 'unsafe' (not having HTTP method
- remote IP Address
- django auth username (if logged in with django.contrib.auth)
- request method
- request host
- request path
- python path of the view resolved to
- args passed to the view
- response status code (if not 500)
- exception type (if 500)
Human Readable Messages
A view can set a human readable message onto its log entry: def view(request): if request.method == 'POST': request.log.message = 'Edited a widget'
If you want to add messages to views from third party apps, you can simply add a log_message attribute to the view. from django.contrib.auth.views import login login.log_message = 'Logged In'
You can also specify a callable object instead of a string; Jaktivity will call it with the same arguments as the view and assign the result of the callable to the message.
Log entries may have multiple notes attached to them. You can add a note to a log anytime: def view(request): for item in request.POST.getlist('values'): request.log.note("Adding item %s" % item)
By default Jaktivity will not log requests with an HTTP method of
HEAD. You can adjust what methods jactivity considers 'safe' (meaning they
will not be logged) by setting
ACTIVITY_SAFE_METHODS in your settings. For
instance, if you do not want to log requests with a
DELETE method, set the
JAKTIVITY_SAFE_METHODS = ('GET', 'HEAD', 'DELETE')
You may override the SAFE_METHODS by marking individual views as
view.always_log = True
Saving HTTP Headers
By default, Jaktivity does not save any of the HTTP Headers. You may specify
which headers you would like to save with the
Example: to save User-Agent strings, add the following to your settings: JAKTIVITY_SAVE_HEADERS = ('HTTP_USER_AGENT',)
Saving HTTP Parameters
Jaktivity records all HTTP parameters, unless they are named any of the following:
You may override this list with the
Noah Silas (firstname.lastname@example.org)