Skip to content

Commit

Permalink
Capture Django errors as Github issues
Browse files Browse the repository at this point in the history
  • Loading branch information
richaagarwal committed Sep 14, 2017
1 parent f2a6e28 commit 18404b8
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
14 changes: 14 additions & 0 deletions cfgov/alerts/logging_handlers.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import logging

from alerts.github_alert import GithubAlert


class CFGovErrorHandler(logging.Handler):
def __init__(self):
logging.Handler.__init__(self)

def emit(self, record):
GithubAlert({}).post(
title=record.message[:30],
body=record.message,
)
6 changes: 5 additions & 1 deletion cfgov/cfgov/settings/production.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,10 @@
'level': 'DEBUG',
'class': 'logging.StreamHandler',
},
'db': {
'level': 'ERROR',
'class': 'alerts.logging_handlers.CFGovErrorHandler',
}
'syslog': {
'address': syslog_device,
'class': 'logging.handlers.SysLogHandler',
Expand All @@ -49,7 +53,7 @@
},
'loggers': {
'django.request': {
'handlers': ['console'],
'handlers': ['console', 'db'],
'level': 'WARNING',
'propagate': True,
},
Expand Down

0 comments on commit 18404b8

Please sign in to comment.