Skip to main content

Per-model audit logs to TABLENAME_log with entry-point capture (HTTP/management/shell/celery)

Project description

Awesome Audit Log for Django

codecov

This is an awesome package to have your models logs in corresponding _log tables.

Having a single model/table as audit storage can cause heavy db operation and useless for large applications.

With this package you will have each model log in a separate table which can be beneficial if you want to truncate a specific model logs or run a query on them.

You can choose between having logs table in your default database or adding a new backend db as logs db.

Supported DBs to store logs:

  1. PostgreSQL
  2. MySQL
  3. SQLite

This package is in its early stage development and the following features will be added ASAP:

  1. Utilizing celery tasks to store audit logs
  2. Release it!
  3. Log rotation
  4. Mongo DB support
  5. Add management, shell, celery as entry point of logs
  6. Document page!

Compatible With

This package works on the below listed Django, Python versions and Databases.

  • Django versions: 4.2, 5.0, 5.1
  • Python versions: 3.10, 3.11, 3.12
  • Databases: SQLite, PostgreSQL, MySQL

Installation

  1. Add App
INSTALLED_APPS = [
    # ...
    'awesome_audit_log.apps.AwesomeAuditLogConfig',
]
  1. Add Middleware
MIDDLEWARE = [
    # ...
    "awesome_audit_log.middleware.RequestEntryPointMiddleware",
]
  1. Settings
AWESOME_AUDIT_LOG = {
    "ENABLED": True,
    "DATABASE_ALIAS": "default",
    "ASYNC": False,
    # "all" or list like ["app_label.ModelA", "app.ModelB"]
    "AUDIT_MODELS": "all",
    # like AUDIT_MODELS but for opt-out, useful when AUDIT_MODELS set to all
    "NOT_AUDIT_MODELS": None,
    "CAPTURE_HTTP": True,
    # set to False means if audit db is unavailable, silently skip logging (with a warning) instead of raising
    "RAISE_ERROR_IF_DB_UNAVAILABLE": False,
    # if audit alias missing/unavailable, use 'default' intentionally, this requires RAISE_ERROR_IF_DB_UNAVAILABLE is set to False
    "FALLBACK_TO_DEFAULT": False,
}

Development

Preparation

# Install dependencies
poetry install

Running Tests and Linter Locally

# Run tests
poetry run pytest

# Run linting
poetry run ruff check awesome_audit_log tests
poetry run ruff format --check awesome_audit_log tests

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

awesome_audit_log_django-0.1.0.tar.gz (7.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

awesome_audit_log_django-0.1.0-py3-none-any.whl (10.1 kB view details)

Uploaded Python 3

File details

Details for the file awesome_audit_log_django-0.1.0.tar.gz.

File metadata

  • Download URL: awesome_audit_log_django-0.1.0.tar.gz
  • Upload date:
  • Size: 7.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.2.0 CPython/3.12.11 Linux/6.11.0-1018-azure

File hashes

Hashes for awesome_audit_log_django-0.1.0.tar.gz
Algorithm Hash digest
SHA256 d6bd4cf1d1223c8897ab317dcb70a80cb38a1ae8395c486220ddd03c473465a0
MD5 46937d8cfcff4d61c0befcd1b1fa2ddc
BLAKE2b-256 a9768b7086ed1db843fb6a05b9a8c1897b3ee9e605c9ab9513232cce274f8efc

See more details on using hashes here.

File details

Details for the file awesome_audit_log_django-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for awesome_audit_log_django-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 e035a6a26dbbeb0c1f13ab2302c5ae17820bf14e0126b0d30aa57561b917fe52
MD5 4d0869ed313d898177762776e7811012
BLAKE2b-256 171c019ba52c517d069f8afb3c949902b15cfb556b2481df8c0a0f514809f010

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page