Installation and Usage¶
Install django-eventlog via pip[env] as usual from Pypi.
$ pip install django-eventlog
eventlog.apps.EventLogConfig to your
setting and migrate the database as usual.
INSTALLED_APPS = [ # ... 'eventlog.apps.EventLogConfig', ]
If you’re using Django 1.8 or earlier 😳 you can use the
name here instead of the
EventLogConfig. But you won’t be able to set
`Custom Event Types`_.
INSTALLED_APPS = [ # ... 'eventlog', ]
A new Event group is started by the
EventGroup object, which you can call
with individual “types” similar to logging levels in Python logging.
from eventlog.events import EventGroup # Start a new Event group e = EventGroup() e.info('Starting to send 100000 emails to all users.', initiator='Mail Sender') # ... sending 100000 totally not spam emails... e.info('All emails sent!', initiator='Mail Sender')
This example will store two
info events. Each event will show up in the
Django Admin changelog view. If you hover over one, it will highlight all
related events as well.
Event types are pre-defined in django-eventlog, but you can define your own
(see `Custom Event Types`_). You can use them to distinct your events and also filter them in
the admin view later. For example to only see
Currently these event types are defined:
You can notify yourself via email by adding the
to a log call.
e = EventGroup() e.info('Conquered the world!', initiator='The cat', email@example.com')
You can also pass
send_mail to the
EventGroup class. This way it’s
globally enabled for all events of this group.
e = EventGroup(firstname.lastname@example.org') e.info('This will send one email.') e.info('This will send one email as well.')