[pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci
This commit is contained in:
pre-commit-ci[bot] 2023-04-24 01:25:18 +00:00
parent 3efdc631f7
commit 15e702f5e2
2 changed files with 11 additions and 8 deletions

View File

@ -3,6 +3,7 @@ import logging
logger = logging.getLogger(__name__)
class AccessLogGenerator:
"""
Object that implements the Daphne "action logger" internal interface in
@ -13,9 +14,11 @@ class AccessLogGenerator:
if stream:
logger.propagate = False
handler = logging.StreamHandler(stream)
formatter = logging.Formatter('%(host)s %(ident)s %(user)s [%(asctime)s] "%{request} %(message)s" '
'%(status)s %(length)s'
"%d/%b/%Y:%H:%M:%S")
formatter = logging.Formatter(
'%(host)s %(ident)s %(user)s [%(asctime)s] "%{request} %(message)s" '
"%(status)s %(length)s"
"%d/%b/%Y:%H:%M:%S"
)
handler.setFormatter(fmt=formatter)
logger.addHandler(handler)
else:
@ -78,5 +81,5 @@ class AccessLogGenerator:
"user": user or "-",
"status": status or "-",
"length": length or "-",
}
},
)

View File

@ -228,7 +228,9 @@ class CommandLineInterface:
elif args.verbosity >= 1:
access_log_stream = sys.stdout
access_logger = AccessLogGenerator(access_log_stream) if access_log_stream else None
access_logger = (
AccessLogGenerator(access_log_stream) if access_log_stream else None
)
# Import application
sys.path.insert(0, ".")
@ -272,9 +274,7 @@ class CommandLineInterface:
websocket_connect_timeout=args.websocket_connect_timeout,
websocket_handshake_timeout=args.websocket_connect_timeout,
application_close_timeout=args.application_close_timeout,
action_logger=access_logger
if access_log_stream
else None,
action_logger=access_logger if access_log_stream else None,
root_path=args.root_path,
verbosity=args.verbosity,
proxy_forwarded_address_header=self._get_forwarded_host(args=args),