django-eventlog


Namedjango-eventlog JSON
Version 2.0 PyPI version JSON
download
home_pagehttps://github.com/bartTC/django-eventlog
Summarydjango-eventlog stores event messages in a Django model.
upload_time2024-03-10 12:49:47
maintainer
docs_urlNone
authorMartin Mahner
requires_python>=3.8
licenseMIT
keywords django logging logger events
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            [![](https://img.shields.io/pypi/v/django-eventlog.svg)](https://pypi.org/project/django-eventlog/)
[![](https://github.com/bartTC/django-eventlog/actions/workflows/push.yml/badge.svg)](https://github.com/bartTC/django-eventlog/actions/workflows/push.yml)
[![](https://codecov.io/github/bartTC/django-eventlog/graph/badge.svg?token=YLXXbCawUQ)](https://codecov.io/github/bartTC/django-eventlog)

-----

📖 **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       |  —  |  —  |  ✓   |  ✓   |  ✓   |

# django-eventlog

<img src="https://github.com/bartTC/django-eventlog/raw/main/docs/_static/logo.webp" alt="djang-eventlog Logo" width="300"/>

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:

```python
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.

```python
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:

![](https://github.com/bartTC/django-eventlog/raw/main/docs/_static/change_list.png)

The details view of an event will list all other events of this group so you
can track the progress:

![](https://github.com/bartTC/django-eventlog/raw/main/docs/_static/change_form.png)

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.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.

  ```python
  event_types = {
      "info": {
          "label": _("Info"),
          "color": None,
          "bgcolor": None,
      },
      "warning": {
          "label": _("Warning"),
          "color": None,
          "bgcolor": None,
      },
      ...
  ```

  The dictionary is now a `EventTypeList` of `EventType` dataclasses:

  ```python
  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.


            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/bartTC/django-eventlog",
    "name": "django-eventlog",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.8",
    "maintainer_email": "",
    "keywords": "django,logging,logger,events",
    "author": "Martin Mahner",
    "author_email": "martin@mahner.org",
    "download_url": "https://files.pythonhosted.org/packages/6c/4e/12bbc99c8ef581656ad02162680cee06a2f097c39c6dd07b2aef6b6f6046/django-eventlog-2.0.tar.gz",
    "platform": null,
    "description": "[![](https://img.shields.io/pypi/v/django-eventlog.svg)](https://pypi.org/project/django-eventlog/)\n[![](https://github.com/bartTC/django-eventlog/actions/workflows/push.yml/badge.svg)](https://github.com/bartTC/django-eventlog/actions/workflows/push.yml)\n[![](https://codecov.io/github/bartTC/django-eventlog/graph/badge.svg?token=YLXXbCawUQ)](https://codecov.io/github/bartTC/django-eventlog)\n\n-----\n\n\ud83d\udcd6 **Full documentation: https://barttc.github.io/django-eventlog/**\n\n*Compatibility Matrix:*\n\n| Py/Dj     | 3.8 | 3.9 | 3.10 | 3.11 | 3.12 |\n| --------- | --- | --- | ---- | ---- | ---- |\n| 3.2 (LTS) |  \u2713  |  \u2713  |  \u2713   |  \u2713   |  \u2713   |\n| 4.0       |  \u2713  |  \u2713  |  \u2713   |  \u2713   |  \u2713   |\n| 4.1       |  \u2713  |  \u2713  |  \u2713   |  \u2713   |  \u2713   |\n| 4.2 (LTS) |  \u2713  |  \u2713  |  \u2713   |  \u2713   |  \u2713   |\n| 5.0       |  \u2014  |  \u2014  |  \u2713   |  \u2713   |  \u2713   |\n\n# django-eventlog\n\n<img src=\"https://github.com/bartTC/django-eventlog/raw/main/docs/_static/logo.webp\" alt=\"djang-eventlog Logo\" width=\"300\"/>\n\ndjango-eventlog is a very simple event logger you can use to track certain actions in \nyour code. Events are stored in a Django model and can be viewed in the Django Admin.\n\nUsage Example:\n\n```python\nfrom eventlog import EventGroup\n\ne = EventGroup()                       # Start a new Event Group\ne.info('About to send 1000 mails.',    # Trigger an Event\n       initiator='Mailer Daemon')\ntry:\n    # ... sending 1000 mails\n    e.info('All emails sent!',         # Trigger an Event in the same group,\n           initiator='Mailer Daemon')  # so they are combined in the admin.\nexcept Exception:\n    e.error('There was an error sending the emails.',\n            initiator='Mailer Daemon')\n```\n\nYou can reuse an event group by specifying a group name and attach optional data. Data \nmust be JSON serializable.\n\n```python\nfrom eventlog import EventGroup\n\ndef purchase():\n    e = EventGroup(group_id=f\"Order {self.order.pk}\")\n    e.info(\"Sent order to Shopify\", data={\"items\": [1, 2, 3]})\n\ndef subscribe_newsletter():\n    e = EventGroup(group_id=f\"Order {self.order.pk}\")\n    e.info(\"User subscribed to newsletter on checkout\", data={\"email\": \"user@example.com\"})\n```\n\nEvents can be grouped in a \"Event Group\" and when hovering over one item in the admin, \nall events of the same group are highlighted:\n\n![](https://github.com/bartTC/django-eventlog/raw/main/docs/_static/change_list.png)\n\nThe details view of an event will list all other events of this group so you\ncan track the progress:\n\n![](https://github.com/bartTC/django-eventlog/raw/main/docs/_static/change_form.png)\n\nWhile looking similar, it's not intended to be a replacement for your regular Python \n`logging` facility, rather an addition to it.\n\ndjango-eventlog stores it's data in a regular database model, so each log entry will \ntrigger a SQL Insert. Therefore you should be careful using it in high performance \nand/or high volume environments.\n\n# Changelog\n\n## 2.0 (2024-03-10)\n\n- Overall test and code refactor.\n- Documentation now done with MKDocs.\n- Timeline in Admin change form now supports delays of days and hours, instead of just minutes.\n- *Backwards incompatible:* Removed undocumented `Event.objects.purge()` queryset method.\n- *Backwards incompatible:* The list of event types defined in the app config is now\n  set via Python dataclasses rather than a dictionary. The migration is straightforward.\n\n  ```python\n  event_types = {\n      \"info\": {\n          \"label\": _(\"Info\"),\n          \"color\": None,\n          \"bgcolor\": None,\n      },\n      \"warning\": {\n          \"label\": _(\"Warning\"),\n          \"color\": None,\n          \"bgcolor\": None,\n      },\n      ...\n  ```\n\n  The dictionary is now a `EventTypeList` of `EventType` dataclasses:\n\n  ```python\n  from django.utils.translation import gettext_lazy as _\n  from eventlog.datastructures import EventType, EventTypeList\n  \n  # List of event types to be used in events. A list of `EventType` classes\n  event_types = EventTypeList(\n      EventType(name=\"info\", label=_(\"Info\")),\n      EventType(name=\"warning\", label=_(\"Warning\")),\n      EventType(name=\"error\", label=_(\"Error\"), color=\"red\"),\n      EventType(name=\"critical\", label=_(\"Critical\"), color=\"white\", bgcolor=\"red\"),\n  )\n  ```\n  \n  You will only need to do this change if you've earlier overridden the event_type property.\n\n## 1.5 (2024-03-08)\n\n- Event can have optional, JSON serializable data attached.\n- Fixed dark mode colors.\n- Various Admin UI improvements.\n\n## 1.4 (2024-03-05)\n\n- Event groups can now have arbitrary names instead of UUIDs.\n- Event comments is a textfield.\n- Fixed potential migration warnings around AutoFields.\n\n## 1.3 (2023-10-04)\n\n- Python 3.12 compatibility\n- Django 5.0 support\n- Type Annotations\n\n## 1.2 (2023-04-28)\n\n- Python 3.7 to 3.11 compatibility\n- Django 3.2 to 4.2 support\n\n## 1.1 (2018-05-11)\n\n- Added ability to manually set a group id to make an EventGroup object\n  reusable through threads.\n\n## 1.0 (2018-02-13)\n\n- Production ready 1.0 release.\n- The details Admin view now displays all events of the group with an\n  annotated delay, so you can see the progress of the group.\n\n## 0.9 (2018-02-13)\n\n- Initial release.\n- Django 1.8 to 2.0 compatibility.\n- Python 2.7 to 3.6 compatibility.\n\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "django-eventlog stores event messages in a Django model.",
    "version": "2.0",
    "project_urls": {
        "Documentation": "https://barttc.github.io/django-eventlog/",
        "Homepage": "https://github.com/bartTC/django-eventlog",
        "Source": "https://github.com/bartTC/django-eventlog"
    },
    "split_keywords": [
        "django",
        "logging",
        "logger",
        "events"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "fb5723a8c14e6a8c1f9b9df4a7b861fc87cf81a494a204fbf6de82a46981260c",
                "md5": "a0ed2b13794027f4edff1f348e88c095",
                "sha256": "4c97042588ed2931034efe7e576d079a287caf53b3f8f29cce93801eaaee12e2"
            },
            "downloads": -1,
            "filename": "django_eventlog-2.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "a0ed2b13794027f4edff1f348e88c095",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.8",
            "size": 17872,
            "upload_time": "2024-03-10T12:49:44",
            "upload_time_iso_8601": "2024-03-10T12:49:44.754346Z",
            "url": "https://files.pythonhosted.org/packages/fb/57/23a8c14e6a8c1f9b9df4a7b861fc87cf81a494a204fbf6de82a46981260c/django_eventlog-2.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "6c4e12bbc99c8ef581656ad02162680cee06a2f097c39c6dd07b2aef6b6f6046",
                "md5": "cddfef7d84e740d590f1ccb52e43c5ae",
                "sha256": "8d77fb3be4928720a6592c503d9d730c479f3823e07c5e6ff22cc21da7e3e433"
            },
            "downloads": -1,
            "filename": "django-eventlog-2.0.tar.gz",
            "has_sig": false,
            "md5_digest": "cddfef7d84e740d590f1ccb52e43c5ae",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.8",
            "size": 897834,
            "upload_time": "2024-03-10T12:49:47",
            "upload_time_iso_8601": "2024-03-10T12:49:47.616083Z",
            "url": "https://files.pythonhosted.org/packages/6c/4e/12bbc99c8ef581656ad02162680cee06a2f097c39c6dd07b2aef6b6f6046/django-eventlog-2.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-03-10 12:49:47",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "bartTC",
    "github_project": "django-eventlog",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "tox": true,
    "lcname": "django-eventlog"
}
        
Elapsed time: 0.26047s