mirror of
https://github.com/django/daphne.git
synced 2024-11-21 23:46:33 +03:00
[pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
This commit is contained in:
parent
3efdc631f7
commit
15e702f5e2
|
@ -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 "-",
|
||||
}
|
||||
},
|
||||
)
|
||||
|
|
|
@ -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),
|
||||
|
|
Loading…
Reference in New Issue
Block a user