diff --git a/sanic/__main__.py b/sanic/__main__.py index 1473aa5f..594256f8 100644 --- a/sanic/__main__.py +++ b/sanic/__main__.py @@ -37,8 +37,8 @@ if __name__ == "__main__": workers=args.workers, debug=args.debug, ssl=ssl) except ImportError as e: logger.error("No module named {} found.\n" - " Example File: project/sanic_server.py -> app\n" - " Example Module: project.sanic_server.app" - .format(e.name)) + " Example File: project/sanic_server.py -> app\n" + " Example Module: project.sanic_server.app" + .format(e.name)) except ValueError as e: logger.error("{}".format(e)) diff --git a/sanic/config.py b/sanic/config.py index b5430445..a79c1c12 100644 --- a/sanic/config.py +++ b/sanic/config.py @@ -1,7 +1,4 @@ import os -import sys -import syslog -import platform import types diff --git a/sanic/log.py b/sanic/log.py index 72636cd0..f9f96005 100644 --- a/sanic/log.py +++ b/sanic/log.py @@ -2,58 +2,58 @@ import logging LOGGING_CONFIG_DEFAULTS = dict( - version=1, - disable_existing_loggers=False, + version=1, + disable_existing_loggers=False, - loggers={ - "root": { - "level": "INFO", - "handlers": ["console"] - }, - "sanic.error": { - "level": "INFO", - "handlers": ["error_console"], - "propagate": True, - "qualname": "sanic.error" - }, + loggers={ + "root": { + "level": "INFO", + "handlers": ["console"] + }, + "sanic.error": { + "level": "INFO", + "handlers": ["error_console"], + "propagate": True, + "qualname": "sanic.error" + }, - "sanic.access": { - "level": "INFO", - "handlers": ["access_console"], - "propagate": True, - "qualname": "sanic.access" - } - }, - handlers={ - "console": { - "class": "logging.StreamHandler", - "formatter": "generic", - "stream": "sys.stdout" - }, - "error_console": { - "class": "logging.StreamHandler", - "formatter": "generic", - "stream": "sys.stderr" - }, - "access_console": { - "class": "logging.StreamHandler", - "formatter": "access", - "stream": "sys.stdout" - }, - }, - formatters={ - "generic": { - "format": "%(asctime)s [%(process)d] [%(levelname)s] %(message)s", - "datefmt": "[%Y-%m-%d %H:%M:%S %z]", - "class": "logging.Formatter" - }, - "access": { - "format": "%(asctime)s - (%(name)s)[%(levelname)s][%(host)s]: " + - "%(request)s %(message)s %(status)d %(byte)d", - "datefmt": "[%Y-%m-%d %H:%M:%S %z]", - "class": "logging.Formatter" - }, + "sanic.access": { + "level": "INFO", + "handlers": ["access_console"], + "propagate": True, + "qualname": "sanic.access" } + }, + handlers={ + "console": { + "class": "logging.StreamHandler", + "formatter": "generic", + "stream": "sys.stdout" + }, + "error_console": { + "class": "logging.StreamHandler", + "formatter": "generic", + "stream": "sys.stderr" + }, + "access_console": { + "class": "logging.StreamHandler", + "formatter": "access", + "stream": "sys.stdout" + }, + }, + formatters={ + "generic": { + "format": "%(asctime)s [%(process)d] [%(levelname)s] %(message)s", + "datefmt": "[%Y-%m-%d %H:%M:%S %z]", + "class": "logging.Formatter" + }, + "access": { + "format": "%(asctime)s - (%(name)s)[%(levelname)s][%(host)s]: " + + "%(request)s %(message)s %(status)d %(byte)d", + "datefmt": "[%Y-%m-%d %H:%M:%S %z]", + "class": "logging.Formatter" + }, + } ) diff --git a/sanic/server.py b/sanic/server.py index 7764b120..75c4ee55 100644 --- a/sanic/server.py +++ b/sanic/server.py @@ -24,7 +24,7 @@ try: except ImportError: async_loop = asyncio -from sanic.log import logger, access_logger, error_logger +from sanic.log import logger, access_logger from sanic.response import HTTPResponse from sanic.request import Request from sanic.exceptions import ( @@ -424,9 +424,9 @@ def serve(host, port, request_handler, error_handler, before_start=None, request_timeout=60, ssl=None, sock=None, request_max_size=None, reuse_port=False, loop=None, protocol=HttpProtocol, backlog=100, register_sys_signals=True, run_async=False, connections=None, - signal=Signal(), request_class=None, access_log=True, keep_alive=True, - is_request_stream=False, router=None, websocket_max_size=None, - websocket_max_queue=None, state=None, + signal=Signal(), request_class=None, access_log=True, + keep_alive=True, is_request_stream=False, router=None, + websocket_max_size=None, websocket_max_queue=None, state=None, graceful_shutdown_timeout=15.0): """Start asynchronous HTTP Server on an individual process. @@ -519,8 +519,9 @@ def serve(host, port, request_handler, error_handler, before_start=None, try: loop.add_signal_handler(_signal, loop.stop) except NotImplementedError: - logger.warn('Sanic tried to use loop.add_signal_handler but it is' - ' not implemented on this platform.') + logger.warn( + 'Sanic tried to use loop.add_signal_handler but it is' + ' not implemented on this platform.') pid = os.getpid() try: logger.info('Starting worker [{}]'.format(pid))