Skip to content

Commit

Permalink
[pre-commit.ci] auto fixes from pre-commit.com hooks
Browse files Browse the repository at this point in the history
for more information, see https://pre-commit.ci
  • Loading branch information
pre-commit-ci[bot] authored and mbidewell committed Dec 30, 2024
1 parent d96fa9f commit a1ae539
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 8 deletions.
11 changes: 7 additions & 4 deletions daphne/access.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

logger = logging.getLogger(__name__)


class AccessLogGenerator:
"""
Object that implements the Daphne "action logger" internal interface in
Expand All @@ -13,9 +14,11 @@ def __init__(self, stream):
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:
Expand Down Expand Up @@ -78,5 +81,5 @@ def write_entry(
"user": user or "-",
"status": status or "-",
"length": length or "-",
}
},
)
8 changes: 4 additions & 4 deletions daphne/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,9 @@ def run(self, args):
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, ".")
Expand Down Expand Up @@ -272,9 +274,7 @@ def run(self, args):
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),
Expand Down

0 comments on commit a1ae539

Please sign in to comment.