Skip to main content

Django model with log

Project description

KF Django Model with Log

Model with log for django

Installation

With requirements.txt

Add the following line in your requirements.txt file:

modelwithlog

With PIP

$ pip install modelwithlog

Getting Started

Allow to create a model with log, adding a log field to the model. This create a log message with the formated datetime and a message

Format example:
[2019-03-15 03:00:02] My message

Only must define logger in your model

For example:

import logging

logger = logging.getLogger(__name__)


class MyModel(ModelWithLog):

    logger = logger

    class Meta:
        verbose_name = _('MyModel')
        verbose_name_plural = _('MyModels')

    my_field = models.<Tipe>
    ....

Also, this model allows to define the logger level for that log. This are the differents levels loggers

INFO

Set log level to Info

DEBUG

Set log level to debug

WARNING

Set log level to warning

ERROR

Set log level to error

CRITICAL

Set log level to critical

How to use it

Only call your level error with yo message error

For example:
mymodel.info("MY ERROR")

Project details


Release history Release notifications | RSS feed

This version

0.1

Download files

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

Source Distribution

modelwithlog-0.1.tar.gz (2.2 kB view details)

Uploaded Source

File details

Details for the file modelwithlog-0.1.tar.gz.

File metadata

  • Download URL: modelwithlog-0.1.tar.gz
  • Upload date:
  • Size: 2.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/45.2.0 requests-toolbelt/0.9.1 tqdm/4.43.0 CPython/3.7.6

File hashes

Hashes for modelwithlog-0.1.tar.gz
Algorithm Hash digest
SHA256 8fa835fe25e52fe4044d39a38fd12a005087ef1cf0f8734053e12001434a7d9b
MD5 a7412dd48e6f42cb8ba2f264f14e1ba4
BLAKE2b-256 25f0d894835b2bc0505b7357e9da636afb401e270cf01e279c476dbc2b4a3445

See more details on using hashes here.

Supported by

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