Skip to content
This repository has been archived by the owner on Jan 22, 2022. It is now read-only.

Latest commit

 

History

History
64 lines (52 loc) · 1.97 KB

README.md

File metadata and controls

64 lines (52 loc) · 1.97 KB

mozilla-cloud-services-logger

Deprecated / Unmaintained - This project is no longer maintained. Consider using mozilla-services/python-dockerflow instead.

Build Status

This package provides two things:

  1. mozilla_cloud_services_logger.formatters.JsonLogFormatter: a Python logging Formatter that produces messages following the JSON schema for a common application logging format defined by Mozilla Cloud Services.

  2. mozilla_cloud_services_logger.django.middleware.RequestSummaryLogger: Django middleware that emits the request.summary log event on every request.

Examples

Django settings.py:

MIDDLEWARE_CLASSES = (
    # ...
    'mozilla_cloud_services_logger.django.middleware.RequestSummaryLogger',
    # ...
)

LOGGING = {
    'version': 1,
    'formatters': {
        'json': {
            '()': 'mozilla_cloud_services_logger.formatters.JsonLogFormatter',
            'logger_name': 'MySiteName'
        }
    },
    'handlers': {
        'console': {
            'level': 'DEBUG',
            'class': 'logging.StreamHandler',
            'formatter': 'json'
        },
    },
    'loggers': {
        'request.summary': {
            'handlers': ['console'],
            'level': 'DEBUG',
        },
    }
}

Testing

pip install jsonschema testfixtures
python tests.py