logging: Add a setting to aid manual testing of error-notif changes.

This is nicer than the "For manual testing ..." comment. :-)
Also as a proper setting we can have it control some logging I
added locally while testing my recent changes to pika logging.
This commit is contained in:
Greg Price 2018-03-20 17:03:12 -07:00 committed by Greg Price
parent fe0f1edddb
commit e44a8b8de9
2 changed files with 13 additions and 2 deletions

View File

@ -122,6 +122,12 @@ class AdminNotifyHandler(logging.Handler):
logging.warning(report['message'], exc_info=True)
report['stack_trace'] = "See /var/log/zulip/errors.log"
if settings.DEBUG_ERROR_REPORTING: # nocoverage
logging.warning("Reporting an error to admins...")
logging.warning("Reporting an error to admins: {} {} {} {} {}" .format(
record.levelname, report['logger_name'], report['log_module'],
report['message'], report['stack_trace']))
try:
if settings.STAGING_ERROR_NOTIFICATIONS:
# On staging, process the report directly so it can happen inside this

View File

@ -291,6 +291,11 @@ DEFAULT_SETTINGS.update({
# TODO: Investigate whether this should be removed and set one way or other.
'SAVE_FRONTEND_STACKTRACES': False,
# If True, disable rate-limiting and other filters on sending error messages
# to admins, and enable logging on the error-reporting itself. Useful
# mainly in development.
'DEBUG_ERROR_REPORTING': False,
# Whether to flush memcached after data migrations. Because of
# how we do deployments in a way that avoids reusing memcached,
# this is disabled in production, but we need it in development.
@ -1359,8 +1364,8 @@ LOGGING = {
'zulip_admins': {
'level': 'ERROR',
'class': 'zerver.logging_handlers.AdminNotifyHandler',
# For manual testing of this handler, delete the `filters` line.
'filters': ['ZulipLimiter', 'require_debug_false', 'require_really_deployed'],
'filters': (['ZulipLimiter', 'require_debug_false', 'require_really_deployed']
if not DEBUG_ERROR_REPORTING else []),
'formatter': 'default'
},
'console': {