From d8cebe1188bf03d424639b4f944c15f01dad668c Mon Sep 17 00:00:00 2001 From: lanf0n Date: Tue, 19 Sep 2017 18:14:25 +0800 Subject: [PATCH] to fix if platform is windows. --- sanic/config.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/sanic/config.py b/sanic/config.py index 0c2cc701..ec2dd5ed 100644 --- a/sanic/config.py +++ b/sanic/config.py @@ -1,6 +1,5 @@ import os import sys -import syslog import platform import types @@ -8,6 +7,11 @@ from sanic.log import DefaultFilter SANIC_PREFIX = 'SANIC_' +try: + from syslog import LOG_DAEMON +except ImportError: + LOG_DAEMON = 24 + _address_dict = { 'Windows': ('localhost', 514), 'Darwin': '/var/run/syslog', @@ -66,7 +70,7 @@ LOGGING = { 'class': 'logging.handlers.SysLogHandler', 'address': _address_dict.get(platform.system(), ('localhost', 514)), - 'facility': syslog.LOG_DAEMON, + 'facility': LOG_DAEMON, 'filters': ['accessFilter'], 'formatter': 'access' }, @@ -74,7 +78,7 @@ LOGGING = { 'class': 'logging.handlers.SysLogHandler', 'address': _address_dict.get(platform.system(), ('localhost', 514)), - 'facility': syslog.LOG_DAEMON, + 'facility': LOG_DAEMON, 'filters': ['errorFilter'], 'formatter': 'simple' },