📖 Full documentation: https://barttc.github.io/django-eventlog/
Compatibility Matrix:
| Py/Dj | 3.8 | 3.9 | 3.10 | 3.11 | 3.12 |
|---|---|---|---|---|---|
| 3.2 (LTS) | ✓ | ✓ | ✓ | ✓ | ✓ |
| 4.0 | ✓ | ✓ | ✓ | ✓ | ✓ |
| 4.1 | ✓ | ✓ | ✓ | ✓ | ✓ |
| 4.2 (LTS) | ✓ | ✓ | ✓ | ✓ | ✓ |
| 5.0 | — | — | ✓ | ✓ | ✓ |
| 5.1 | — | — | ✓ | ✓ | ✓ |
django-eventlog
django-eventlog is a very simple event logger you can use to track certain actions in your code. Events are stored in a Django model and can be viewed in the Django Admin.
Usage Example:
from eventlog import EventGroup
e = EventGroup() # Start a new Event Group
e.info('About to send 1000 mails.', # Trigger an Event
initiator='Mailer Daemon')
try:
# ... sending 1000 mails
e.info('All emails sent!', # Trigger an Event in the same group,
initiator='Mailer Daemon') # so they are combined in the admin.
except Exception:
e.error('There was an error sending the emails.',
initiator='Mailer Daemon')
You can reuse an event group by specifying a group name and attach optional data. Data must be JSON serializable.
from eventlog import EventGroup
def purchase():
e = EventGroup(group_id=f"Order {self.order.pk}")
e.info("Sent order to Shopify", data={"items": [1, 2, 3]})
def subscribe_newsletter():
e = EventGroup(group_id=f"Order {self.order.pk}")
e.info("User subscribed to newsletter on checkout", data={"email": "user@example.com"})
Events can be grouped in a "Event Group" and when hovering over one item in the admin, all events of the same group are highlighted:
The details view of an event will list all other events of this group so you can track the progress:
While looking similar, it's not intended to be a replacement for your regular Python
logging facility, rather an addition to it.
django-eventlog stores it's data in a regular database model, so each log entry will trigger a SQL Insert. Therefore you should be careful using it in high performance and/or high volume environments.
Changelog
2.2.1 (2024-09-02)
- Django 5.1 support
2.2 (2024-06-16)
- Minor typo fixes
- The 'group' db field now uses a DB index.
2.1 (2024-03-20)
- The format and value of the random group id can now be specified using the AppConfig.
- Various improvements to make the Event model swappable via the AppConfig.
- Switch development tooling from Pipenv to Poetry
2.0 (2024-03-10)
-
Overall test and code refactor.
-
Documentation now done with MKDocs.
-
Timeline in Admin change form now supports delays of days and hours, instead of just minutes.
-
Backwards incompatible: Removed undocumented
Event.objects.purge()queryset method. -
Backwards incompatible: The list of event types defined in the app config is now set via Python dataclasses rather than a dictionary. The migration is straightforward.
event_types = { "info": { "label": _("Info"), "color": None, "bgcolor": None, }, "warning": { "label": _("Warning"), "color": None, "bgcolor": None, }, # ... }
The dictionary is now a
EventTypeListofEventTypedataclasses:from django.utils.translation import gettext_lazy as _ from eventlog.datastructures import EventType, EventTypeList # List of event types to be used in events. A list of `EventType` classes event_types = EventTypeList( EventType(name="info", label=_("Info")), EventType(name="warning", label=_("Warning")), EventType(name="error", label=_("Error"), color="red"), EventType(name="critical", label=_("Critical"), color="white", bgcolor="red"), )
You will only need to do this change if you've earlier overridden the event_type property.
1.5 (2024-03-08)
- Event can have optional, JSON serializable data attached.
- Fixed dark mode colors.
- Various Admin UI improvements.
1.4 (2024-03-05)
- Event groups can now have arbitrary names instead of UUIDs.
- Event comments is a textfield.
- Fixed potential migration warnings around AutoFields.
1.3 (2023-10-04)
- Python 3.12 compatibility
- Django 5.0 support
- Type Annotations
1.2 (2023-04-28)
- Python 3.7 to 3.11 compatibility
- Django 3.2 to 4.2 support
1.1 (2018-05-11)
- Added ability to manually set a group id to make an EventGroup object reusable through threads.
1.0 (2018-02-13)
- Production ready 1.0 release.
- The details Admin view now displays all events of the group with an annotated delay, so you can see the progress of the group.
0.9 (2018-02-13)
- Initial release.
- Django 1.8 to 2.0 compatibility.
- Python 2.7 to 3.6 compatibility.
Metadata
Release files for django-eventlog2 2.2.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| django_eventlog2-2.2.1.tar.gz | 17.3 kB | Without provenance | Details for django_eventlog2-2.2.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| django_eventlog2-2.2.1-py3-none-any.whl | Python 3 | none | any | Details for django_eventlog2-2.2.1-py3-none-any.whl |
Total release size: 37.8 kB
Release files / django_eventlog2-2.2.1.tar.gz
| Download URL | django_eventlog2-2.2.1.tar.gz |
|---|---|
| Size | 17.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
01c68c4f7a5be61e08bfd00c8722ff3068096c3a91c2c4c3da8f51765d984c02
|
|
BLAKE2b-256 checksum How to use checksums |
a1aa7e614bfdb7a21aef89a5853fd6d08bb8c968bdc6eed3ed985aeac608d34b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.8.4 CPython/3.10.12 Linux/5.15.167.4-microsoft-standard-WSL2
|
Release files / django_eventlog2-2.2.1-py3-none-any.whl
| Download URL | django_eventlog2-2.2.1-py3-none-any.whl |
|---|---|
| Size | 20.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
78bff0e991b970d6f54e0d942718205e0b8cd83a7cfd15cea76e3d3a5db5a056
|
|
BLAKE2b-256 checksum How to use checksums |
144738a04215dc2ccb4437d4a2150ce907ea46ff471cb80e0a92ee10a03404bc
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.8.4 CPython/3.10.12 Linux/5.15.167.4-microsoft-standard-WSL2
|
Security for django-eventlog2 2.2.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.