Skip to main content

Библиотека логирования изменений данных в БД

Подключение

requirements:

libaudit>=4.1.0,<5.0

settings:

INSTALLED_APPS = [
    ...
    'libaudit',
    ...
]

MIDDLEWARE = [
    ...
    'django.contrib.auth.middleware.AuthenticationMiddleware',
    'libaudit.middleware.AuditLogMiddleware',
    ...
]

LIBAUDIT = {
    'HANDLER': 'libaudit.handlers.database_table',  # или иной обработчик
    'CONTEXT_RESOLVER_CLS': 'my_app.audit.MyAuditContextResolver',
    'EXCLUDED_TABLES': (),  # опционально
    'SETUP_AUDIT_CONTEXT_FOR_READONLY_REQUESTS': False,  # опционально
}

Реализовано два обработчика: хранение в таблице и отправка в стандартный вывод СУБД.

Дополнения: contrib

Запуск тестов

Тесты запускаются через tox. В системе должен быть установлен uv.

Для корректного запуска тестов необходимы следующие значения переменных окружения в системе. Вместо <login> и <password> необходимо подставить данные от УЗ БАРС:

UV_INDEX="internal=http://<login>:<password>@nexus.py.bars.group/repository/pypi-all/simple"
UV_DEFAULT_INDEX="https://pypi.org/simple"
UV_INDEX_STRATEGY=unsafe-best-match
# Для docker 29+
TOX_DOCKER_GATEWAY=localhost

Чтобы не менять значения системных переменных, можно создать .env файл c переменными окружения и запускать команды через python-dotenv.

Установка tox с необходимыми зависимостями:

uv tool install tox --with tox-uv --with m3-tox-docker

Или с использованием python-dotenv:

dotenv run uv tool install tox --with tox-uv --with m3-tox-docker

Запуск тестов:

tox

Через python-dotenv:

dotenv run tox

Metadata

Release files for libaudit 4.3.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for libaudit 4.3.0
File Size Uploaded Provenance Actions
libaudit-4.3.0.tar.gz 24.7 kB Without provenance Details for libaudit-4.3.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for libaudit 4.3.0
File Interpreter ABI Platform Actions
libaudit-4.3.0-py3-none-any.whl Python 3 none any Details for libaudit-4.3.0-py3-none-any.whl

Total release size: 63.7 kB

Release files / libaudit-4.3.0.tar.gz

Download URL libaudit-4.3.0.tar.gz
Size 24.7 kB
Tags Source
SHA-256 checksum
How to use checksums
362911db02e8529099ef817d43a8a6525409a496b371a5833d2ded13dbcc7e47
BLAKE2b-256 checksum
How to use checksums
2ec066dce4d77bc07f92bbe88308c4a0f6ca435ac65145841879faf853082294
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.8.0 pkginfo/2.0 readme-renderer/46.0 requests/2.34.2 requests-toolbelt/1.0.0 urllib3/2.8.0 tqdm/4.70.1 importlib-metadata/10.2.0 keyring/25.7.0 rfc3986/2.0.0 colorama/0.4.6 CPython/3.12.13

Release files / libaudit-4.3.0-py3-none-any.whl

Download URL libaudit-4.3.0-py3-none-any.whl
Size 39.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
c94a7ad20d4470ba94f5d109f8c3c61c08c611d545f3db5b07a0c085fbf0d9e4
BLAKE2b-256 checksum
How to use checksums
bdeb0af85740437377adedd9eaa79f804b0a4d178214b6def3c0c82da54c19c9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.8.0 pkginfo/2.0 readme-renderer/46.0 requests/2.34.2 requests-toolbelt/1.0.0 urllib3/2.8.0 tqdm/4.70.1 importlib-metadata/10.2.0 keyring/25.7.0 rfc3986/2.0.0 colorama/0.4.6 CPython/3.12.13

Security for libaudit 4.3.0

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.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page