mirror of
https://github.com/django/daphne.git
synced 2025-03-12 19:35:47 +03:00
Fix logging formmatting bugs and syntax errors
This commit is contained in:
parent
c741811deb
commit
eb820e3fed
|
@ -14,14 +14,13 @@ class AccessLogGenerator:
|
||||||
logger.propagate = False
|
logger.propagate = False
|
||||||
handler = logging.StreamHandler(stream)
|
handler = logging.StreamHandler(stream)
|
||||||
formatter = logging.Formatter(
|
formatter = logging.Formatter(
|
||||||
'%(host)s %(ident)s %(user)s [%(asctime)s] "%{request} %(message)s" '
|
'%(host)s %(ident)s %(user)s [%(asctime)s] "%(message)s" '
|
||||||
"%(status)s %(length)s"
|
"%(status)s %(length)s",
|
||||||
"%d/%b/%Y:%H:%M:%S"
|
"%d/%b/%Y:%H:%M:%S"
|
||||||
)
|
)
|
||||||
handler.setFormatter(fmt=formatter)
|
handler.setFormatter(fmt=formatter)
|
||||||
logger.addHandler(handler)
|
logger.addHandler(handler)
|
||||||
else:
|
|
||||||
logger.addHandler(logging.NullHandler)
|
|
||||||
|
|
||||||
def __call__(self, protocol, action, details):
|
def __call__(self, protocol, action, details):
|
||||||
"""
|
"""
|
||||||
|
@ -31,7 +30,7 @@ class AccessLogGenerator:
|
||||||
if protocol == "http" and action == "complete":
|
if protocol == "http" and action == "complete":
|
||||||
self.write_entry(
|
self.write_entry(
|
||||||
host=details["client"],
|
host=details["client"],
|
||||||
request="%(method)s",
|
request="%(method)s" % details,
|
||||||
details="%(path)s" % details,
|
details="%(path)s" % details,
|
||||||
status=details["status"],
|
status=details["status"],
|
||||||
length=details["size"],
|
length=details["size"],
|
||||||
|
@ -66,8 +65,9 @@ class AccessLogGenerator:
|
||||||
self, host, request, details, status=None, length=None, ident=None, user=None
|
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
|
Writes an access log. If a file is specified, an NCSA-style entry to the log file
|
||||||
what the entries are for non-HTTP)
|
(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(
|
logger.info(
|
||||||
|
|
Loading…
Reference in New Issue
Block a user