Skip to main content

Flexible, fast and productive logging for Django with UI

Project description

Django LogUi

Sometimes I use this in different projects, so I decided to put it on pypi

Installation

pip install django-logui

Settings

  • Add the application to the project.

    INSTALLED_APPS = [
        #...
        'adjango',
        'logui',
    ]
    
  • In settings.py set the params

    # logui
    from os.path import join
    from logui.classes.logger import LoggingBuilder, Logger
    
    LOGUI_LOGS_DIR = join(BASE_DIR, 'logs')
    LOGUI_REQUEST_RESPONSE_LOGGER_NAME = 'global'
    LOGUI_URL_PREFIX = 'logui/'
    LOGUI_CONTROLLERS_SETTINGS = {
        'auth_required': True,
        'log_name': False,
        'not_auth_redirect': f'/admin/login/?next=/{LOGUI_URL_PREFIX}'
    }
    LOGGING = LoggingBuilder(
        format='{levelname} {asctime}: {message}',
        datefmt='%d-%m %H:%M:%S',
        loggers=(
            Logger(name='tbank', level='DEBUG', include_in=['commerce']),
            Logger(name='order', level='DEBUG', include_in=[]),
            Logger(name='email', level='DEBUG', include_in=[]),
            Logger(name='social_auth', level='DEBUG', include_in=[]),
            Logger(name='consultation', level='DEBUG', include_in=[]),
            Logger(name='commerce', level='DEBUG', include_in=['tbank']),
            Logger(name='global', level='DEBUG', include_in=[
                'tbank',
                'order',
                'email',
                'social_auth',
                'consultation'
                'commerce'
            ]),
        )
    ).build()
    LoggingBuilder.check_loggers(LOGGING)
    
    # adjango
    LOGIN_URL = '/login/'
    ADJANGO_BACKENDS_APPS = BASE_DIR / 'apps'
    ADJANGO_FRONTEND_APPS = BASE_DIR.parent / 'frontend' / 'src' / 'apps'
    ADJANGO_APPS_PREPATH = 'apps.'  # if apps in BASE_DIR/apps/app1,app2...
    # ADJANGO_APPS_PREPATH = None # if in BASE_DIR/app1,app2...
    ADJANGO_EXCEPTION_REPORT_EMAIL = ('ivanhvalevskey@gmail.com',)
    # Template for sending a email report on an uncaught error.
    # Вы можете его переопределить он принимает лишь context={'traceback': 'str'}
    ADJANGO_EXCEPTION_REPORT_TEMPLATE = 'logui/error_report.html'
    
    # adjango использует send_emails для отправки писем синхронно.
    ADJANGO_USE_CELERY_MAIL_REPORT = False  # Использовать ли celery для отправки писем
    ADJANGO_CELERY_SEND_MAIL_TASK = send_mail_task_function  # callable task
    ADJANGO_LOGGER_NAME = 'global'
    ADJANGO_EMAIL_LOGGER_NAME = 'email'
    

    Read more about adjango

  • Add routes

    Only is_staff have access.

    from django.urls import path, include
    # Not use django.conf.settings
    from tests.project.project.settings import LOGUI_URL_PREFIX
    
    urlpatterns = [
        ...
        path(LOGUI_URL_PREFIX, include('logui.routes.views')),
    ]
    
  • Open https://localhost:8000/logui/

    https://localhost:8000/settings.LOGUI_URL_PREFIX

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_logui-0.0.8.tar.gz (92.9 kB view details)

Uploaded Source

Built Distribution

django_logui-0.0.8-py3-none-any.whl (95.3 kB view details)

Uploaded Python 3

File details

Details for the file django_logui-0.0.8.tar.gz.

File metadata

  • Download URL: django_logui-0.0.8.tar.gz
  • Upload date:
  • Size: 92.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.8.6

File hashes

Hashes for django_logui-0.0.8.tar.gz
Algorithm Hash digest
SHA256 3ddeb60dab9926b5374ca4c561121cba141dd8d6639b12c4655b005a3dc0afd1
MD5 925780c728d7a81da6bfb4b1f6847d33
BLAKE2b-256 d6e94881aa2f31b373cd63eece64c74a6c3fd5a39ff2525db9f630fcdbcdc1dc

See more details on using hashes here.

File details

Details for the file django_logui-0.0.8-py3-none-any.whl.

File metadata

File hashes

Hashes for django_logui-0.0.8-py3-none-any.whl
Algorithm Hash digest
SHA256 80aad8241a28f86b797606ab4b8814e33e2747632be03a0a8054e51dcbebe4bc
MD5 af71230e38fc085f99e469e1befc6dcf
BLAKE2b-256 a953bdf8634b48388df038468551c777dbb5cf13edae76be7748d83fe1451fe6

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