valeriansaliou / django-gitlab-logging

:wine_glass: A logging handler for Django that opens GitLab issues on server error.
MIT License
13 stars 7 forks source link

Django GitLab Logging

Gitter

Django GitLab Logging is a custom log handler that has been written with the purpose of auto-opening (and assigning) issues on GitLab everytime something goes south with backend code.

Useful for production deployments, where you want to move the flood of 500 errors you get in your mailbox to your GitLab issue tracker.

Django GitLab Logging is smart enough to recognize similar errors, thus not opening blindly a new issue everytime. It is also capable of re-opening closed issues that are encountered again.

Configuration

# GitLab options
GITLAB_HOST = 'https://gitlab.server.tld'  # Beware: no trailing slash there!
GITLAB_USER = 'gitlab.user'
GITLAB_TOKEN = 'USER_GITLAB_TOKEN'         # Get this from GitLab user account information
GITLAB_PROJECT_ID = 114                    # Get the project ID from the DB
GITLAB_ASSIGNEE_ID = 2                     # Get the assignee ID from the DB (optional, you can drop this parameter)
'handlers': {
    # (....)

    'gitlab_issues': {
        'level': 'ERROR',
        'class': 'gitlab_logging.handlers.GitlabIssuesHandler',
    },
},
LOGGING['loggers'] = {
    'django.request': {
        'handlers': ['all_console', 'django_file', 'gitlab_issues'],
        'level': 'DEBUG',
        'propagate': True,
    },

    # (....)
}

Notes