Skip to main content

Django CommandLog - Django Command logging

https://travis-ci.org/achedeuzot/django-commandlog.svg?branch=master https://coveralls.io/repos/github/achedeuzot/django-commandlog/badge.svg?branch=master

Django CommandLog adds the feature of logging the django management commands into the database so it’s available in the admin interface.

We’ve been using this to check the result of scheduled management commands directly through the admin interface. It works by copying the stream of stdout and stderr.

The decorator also adds some helper methods, see below.

Quick start

  1. Add “django_commandlog” to your INSTALLED_APPS settings like this:

INSTALLED_APPS = [
    ...
    'django_commandlog',
]
  1. Run python manage.py migrate to add the tables of django_commandlog to your database.

3. To log an admin command, add the @command_log decorator above the class (see example below). Thus, it currently supports only custom management commands. If you wish to add this to default django manage commands you’ll have to create a child class with the decorator. Pull/Merge requests are welcome with a fix for this.

@command_log
class SampleCommand(BaseCommand):

    def handle(self, *args, **options):
        ...

Configuration

There are currently no configuration values.

Helper methods

When your class is decorated with @command_log, you have access to additional methods.

CommandLog includes counters for basic CRUD operations (Create, Read, Update, Delete) which can be used through helper methods provided:

add_log_created(10)
add_log_read(30)
add_log_updated(20)
add_log_deleted(30)
add_log_errors(14)

There are two fields used to track the commands or runs: reference and user. Reference is any number you want to track in your manage commands.

You can also add a user to the tracking by using the add_log_user(user) method. user can be a string which will be kept as-is or you can use a settings.AUTH_USER_MODEL object.

add_log_reference("C1235342321")
add_log_user("user:ldap:username")
# or
add_log_user(user_instance)

Requirements

  • python 2.7, 3.4, 3.5

  • django 1.10

Tested on Django 1.10.3

Release files for django-commandlog 0.1.10

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

Source distribution (sdist)

Source distribution for django-commandlog 0.1.10
File Size Uploaded
django-commandlog-0.1.10.tar.gz 10.0 kB Details

Release files / django-commandlog-0.1.10.tar.gz

Download URL django-commandlog-0.1.10.tar.gz
Size 10.0 kB
Tags Source
SHA-256 checksum
How to use checksums
1da886179f247fe5d89ae0897e2950fa3b03ef4e6e162270e321be558802fa43
BLAKE2b-256 checksum
How to use checksums
b4b4ef70bb4c8fa960a41c0b5ea033812beb8e052d83f6869a34624eb59dd813
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release history Release notifications | RSS feed

This release

0.1.10 This release

1 release file

0.1.9

1 release file

0.1.8

1 release file

0.1.7

1 release file

0.1.6

1 release file

0.1.3

1 release file

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