Skip to content

Commit

Permalink
Fix logging formmatting bugs and syntax errors
Browse files Browse the repository at this point in the history
  • Loading branch information
mbidewell committed Jan 6, 2025
1 parent c741811 commit eb820e3
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions daphne/access.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,13 @@ def __init__(self, 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"
'%(host)s %(ident)s %(user)s [%(asctime)s] "%(message)s" '
"%(status)s %(length)s",
"%d/%b/%Y:%H:%M:%S"
)
handler.setFormatter(fmt=formatter)
logger.addHandler(handler)
else:
logger.addHandler(logging.NullHandler)


def __call__(self, protocol, action, details):
"""
Expand All @@ -31,7 +30,7 @@ def __call__(self, protocol, action, details):
if protocol == "http" and action == "complete":
self.write_entry(
host=details["client"],
request="%(method)s",
request="%(method)s" % details,
details="%(path)s" % details,
status=details["status"],
length=details["size"],
Expand Down Expand Up @@ -66,8 +65,9 @@ def write_entry(
self, host, request, details, status=None, length=None, ident=None, user=None
):
"""
Writes an NCSA-style entry to the log file (some liberty is taken with
what the entries are for non-HTTP)
Writes an access log. If a file is specified, an NCSA-style entry to the log file
(some liberty is taken with what the entries are for non-HTTP). The format can be
overriden with logging configuration for 'daphne.access'
"""

logger.info(
Expand Down

0 comments on commit eb820e3

Please sign in to comment.