Skip to main content

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 django-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_logging_config

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

Configuring Loguru

You can pass in a function that configures 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)

Configuring the Default Format

export LOGURU_FORMAT="<blue>{time:HH:mm:ss}</blue> | <red>{name}:{line}</red> | {level} - {message}"

See the record dict documention for other available formatting options. And see color markups for more info on coloring and markups.

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.

Metadata

Release files for django-easy-logging 0.70

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-easy-logging 0.70
File Size Uploaded
django-easy-logging-0.70.tar.gz 3.9 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for django-easy-logging 0.70
File Interpreter ABI Platform
django_easy_logging-0.70-py3-none-any.whl Python 3 none any Details

Total release size: 8.6 kB

Release files / django-easy-logging-0.70.tar.gz

Download URL django-easy-logging-0.70.tar.gz
Size 3.9 kB
Tags Source
SHA-256 checksum
How to use checksums
c318cb34ead1b75483842cae84fcc0dc56dc2fa3bf3e54dd6fba5634732a15cf
BLAKE2b-256 checksum
How to use checksums
315c1db04dc0c3c33a6f9614b906dcedca71193612932f6649bb6ffec45cb6d7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via pdm/2.12.3 CPython/3.10.12

Release files / django_easy_logging-0.70-py3-none-any.whl

Download URL django_easy_logging-0.70-py3-none-any.whl
Size 4.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
10dd64047bc32df31f3fafdc29e307f797faeb1a9eef27f6c4d3ec03006802ac
BLAKE2b-256 checksum
How to use checksums
7154c295b61448d7af9c095dd3bf646a7167633e4ab23baeed8382c13ff3839c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via pdm/2.12.3 CPython/3.10.12

Release history Release notifications | RSS feed

This release

0.70 This release

2 release files

0.60

2 release files

0.50

2 release files

0.4.0

2 release files

0.3.0

2 release files

0.1.0

2 release files

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