Tools for producing a common application logging format defined by Mozilla Cloud Services
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
mozilla_cloud_services_logger
.gitignore
.travis.yml
LICENSE.txt
README.md
setup.cfg
setup.py
tests.py
tox.ini

README.md

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