Commit fe935032 authored by Michal Čihař's avatar Michal Čihař

Better detection of running syslog

Signed-off-by: default avatarMichal Čihař <michal@cihar.com>
parent 6e7edffe
...@@ -311,7 +311,14 @@ DEFAULT_EXCEPTION_REPORTER_FILTER = \ ...@@ -311,7 +311,14 @@ DEFAULT_EXCEPTION_REPORTER_FILTER = \
# - you can also choose 'logfile' to log into separate file # - you can also choose 'logfile' to log into separate file
# after configuring it below # after configuring it below
if DEBUG or not os.path.exists('/dev/log'): # Detect if we can connect to syslog
try:
SysLogHandler(address='/dev/log', facility=SysLogHandler.LOG_LOCAL2)
HAVE_SYSLOG = True
except IOError:
HAVE_SYSLOG = False
if DEBUG or not HAVE_SYSLOG:
DEFAULT_LOG = 'console' DEFAULT_LOG = 'console'
else: else:
DEFAULT_LOG = 'syslog' DEFAULT_LOG = 'syslog'
...@@ -392,7 +399,7 @@ if (os.environ.get('DJANGO_IS_MANAGEMENT_COMMAND', False) and ...@@ -392,7 +399,7 @@ if (os.environ.get('DJANGO_IS_MANAGEMENT_COMMAND', False) and
LOGGING['loggers']['weblate']['handlers'].append('console') LOGGING['loggers']['weblate']['handlers'].append('console')
# Remove syslog setup if it's not present # Remove syslog setup if it's not present
if not os.path.exists('/dev/log'): if not HAVE_SYSLOG:
del LOGGING['handlers']['syslog'] del LOGGING['handlers']['syslog']
# Machine translation API keys # Machine translation API keys
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment