tests: disable syslog logging handler (#51267)
This commit is contained in:
parent
c7362f2418
commit
0f8fe28274
|
@ -50,6 +50,9 @@ DEBUG_LOG_FORMAT = (
|
|||
'%(levelname)s \x1f%(name)s \x1f%(message)s'
|
||||
)
|
||||
|
||||
DISABLE_GLOBAL_HANDLERS = os.environ.get('DISABLE_GLOBAL_HANDLERS') == '1'
|
||||
|
||||
|
||||
LOGGING = {
|
||||
'version': 1,
|
||||
'disable_existing_loggers': True,
|
||||
|
@ -175,20 +178,20 @@ LOGGING = {
|
|||
},
|
||||
# log py.warnings to syslog
|
||||
'py.warnings': {
|
||||
'handlers': ['syslog_no_filter'],
|
||||
'handlers': [] if DISABLE_GLOBAL_HANDLERS else ['syslog_no_filter'],
|
||||
'level': 'WARNING',
|
||||
'propagate': False,
|
||||
},
|
||||
'': {
|
||||
'level': 'DEBUG',
|
||||
'filters': ['request_context'],
|
||||
'handlers': ['syslog', 'mail_admins', 'debug'],
|
||||
'handlers': ([] if DISABLE_GLOBAL_HANDLERS else ['syslog']) + ['mail_admins', 'debug'],
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
# Journald support
|
||||
if os.path.exists('/run/systemd/journal/socket'):
|
||||
if os.path.exists('/run/systemd/journal/socket') and not DISABLE_GLOBAL_HANDLERS:
|
||||
try:
|
||||
from systemd import journal
|
||||
except ImportError:
|
||||
|
@ -203,7 +206,7 @@ if os.path.exists('/run/systemd/journal/socket'):
|
|||
LOGGING['loggers']['']['handlers'].remove('syslog')
|
||||
LOGGING['loggers']['']['handlers'].append('journald')
|
||||
|
||||
elif not os.path.exists('/dev/log'):
|
||||
elif not os.path.exists('/dev/log') and not DISABLE_GLOBAL_HANDLERS:
|
||||
# if three's no syslog (for example when building a docker image), remove
|
||||
# those loggers.
|
||||
LOGGING['loggers']['']['handlers'].remove('syslog')
|
||||
|
|
Loading…
Reference in New Issue