Skip to main content

No project description provided

Project description

Django Easy Logging

Easy Django logging with Loguru

Loguru is an exceeding easy way to do logging in Python. django-easy-logging makes it exceedingly easy to use Loguru in Django. Once integrated you can using existings Python logging mechanisms which are then funneled into Loguru or you can use the Loguru logging methods.

Install

pip install djang-easy-logging

Usage

In your settings.py towards the end of the file add:

from dj_easy_log import load_loguru

load_loguru(globals())

In your other files, use Loguru methods for logging.

from loguru import logger

logger.debug("That's it, beautiful and simple logging!")

logger.info("If you're using Python {}, prefer {feature} of course!", 3.6, feature="f-strings")

Note: Any existing logging is funneled into loguru when using the defualt settings. Loguru is used as a sink as outlined in the docs.

Customization

Log Level

The default log level in DEBUG is INFO. Otherwise the default level is ERROR.

You can override the log level with the env LOGLEVEL.

or

pass in a log level into load_loguru.

Example: load_loguru(globals(), loglevel="WARNING")

Logging Config

The LOGGING config dict is generated automatically or you can pass in your own. The default is created by generate_loggin_config

Example: load_loguru(globals(), logging_config=MY_LOGGING_CONFIG)

Configuring Loguru

You can pass in a function that configure Loguru.

Example:

def setup_loguru(logger, settings_dict):
  if not settings_dict['DEBUG']:
    logger.add("django.log", rotation="100 MB")

load_loguru(globals(), configure_func=setup_loguru)

Shameless Plugs

I built this library originally for the NeutronSync Service. So if you would like to support this project please support the service with a subscription to NeutronSync or a donation to the open source libraries.

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

django-easy-logging-0.1.0.tar.gz (3.9 kB view details)

Uploaded Source

Built Distribution

django_easy_logging-0.1.0-py3-none-any.whl (4.4 kB view details)

Uploaded Python 3

File details

Details for the file django-easy-logging-0.1.0.tar.gz.

File metadata

  • Download URL: django-easy-logging-0.1.0.tar.gz
  • Upload date:
  • Size: 3.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.7.1 importlib_metadata/4.10.0 pkginfo/1.8.2 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.2

File hashes

Hashes for django-easy-logging-0.1.0.tar.gz
Algorithm Hash digest
SHA256 c376e8c0409ce06bf3b13327f8c2be8d6c74e54c14dde6b062849cf3d4bc3d7e
MD5 f888ed439ff43b8764a796ba3e2ef89d
BLAKE2b-256 f830e14ba1954f453db196551945c4c9dd40fa4aae09d2a72d8636cbf6ab3ea1

See more details on using hashes here.

File details

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

File metadata

  • Download URL: django_easy_logging-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 4.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.7.1 importlib_metadata/4.10.0 pkginfo/1.8.2 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.2

File hashes

Hashes for django_easy_logging-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 d5762760448eaa22e5c61079d4d9232d11e70faf18c52feb30e954ea1cf2dcec
MD5 5dac7041eee53762c2541ed1b0227afc
BLAKE2b-256 1db9eaed795ffab9ad52e7f330ef03f766911b51e8c8ef77c55880116f36a8a7

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