HTTP queries logger with flexible filters.
Project description
This django app intended for writing HTTP log to database and/or watch last user activity.
Features:
- DB router for writing logs to another database.
- Filters for ignoring some queries by URL, HTTP methods and response codes.
- Saving anonymous activity as fake user.
- Autocreation log DB (for postgresql)
Install:
$ pip install django-user-activity-log2
settings.py:
INSTALLED_APPS = (
...
'activity_log',
)
MIDDLEWARE_CLASSES = (
...
'activity_log.middleware.ActivityLogMiddleware',
)
# For writing log to another DB
DATABASE_ROUTERS = ['activity_log.router.DatabaseAppsRouter']
DATABASE_APPS_MAPPING = {'activity_log': 'logs'}
# If you set up DATABASE_APPS_MAPPING, but don't set related value in
# DATABASES, it will created automatically using "default" DB settings
# as example.
DATABASES = {
'logs': {
...
},
}
# Create DB automatically (for postgres, and may be mysql).
# We create log database automatically using raw SQL in pre_migrate signal.
# You must insure, that DB user has permissions for creation databases.
# Tested only for postgresql
ACTIVITYLOG_AUTOCREATE_DB = False
# App settings
# Log anonymous actions?
ACTIVITYLOG_ANONYMOUS = True
# Update last activity datetime in user profile. Needs updates for user model.
ACTIVITYLOG_LAST_ACTIVITY = True
# Only this methods will be logged
ACTIVITYLOG_METHODS = ('POST', 'GET')
# List of response statuses, which logged. By default - all logged.
# Don't use with ACTIVITYLOG_EXCLUDE_STATUSES
ACTIVITYLOG_STATUSES = (200, )
# List of response statuses, which ignores. Don't use with ACTIVITYLOG_STATUSES
# ACTIVITYLOG_EXCLUDE_STATUSES = (302, )
# URL substrings, which ignores
ACTIVITYLOG_EXCLUDE_URLS = ('/admin/activity_log/activitylog', )
account/models.py:
from django.contrib.auth.models import AbstractUser
from activity_log.models import UserMixin
# Only for LAST_ACTIVITY = True
class User(AbstractUser, UserMixin):
pass
$ python manage.py migrate & python manage.py migrate --database=logs
If you use ACTIVITYLOG_AUTOCREATE_DB migrations to logs database will be run automatically.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Close
Hashes for django-user-activity-log2-0.0.24.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4187fb311f26918b852a9ce96291e6bf33ab9484967e3b7ad96494b8b011b232 |
|
MD5 | 402ac40a2ae0d62e449768c93e3e064d |
|
BLAKE2b-256 | f9bae4898afaaf7986fcbecac223c57a07425a7aa8318b9c32f3d9c2ade1e9ca |
Close
Hashes for django_user_activity_log2-0.0.24-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | ff6f21dd71572b0f18232194fd3e6740768045f9d6ee2a6acef43706bb505309 |
|
MD5 | 66e5be0daed1785a553f1b19b1f899cf |
|
BLAKE2b-256 | d27417602b3c1a3e689f1f815675d6b59c12f0163e9ccb7f2f317724565d10f4 |