add logging

This commit is contained in:
Aryan Kapoor 2021-07-30 10:30:16 +05:30
parent 36ce9fd1ed
commit 107475005f
3 changed files with 19 additions and 9 deletions

View File

@ -1,6 +1,6 @@
import sys
__version__ = "3.0.2"
__version__ = "1.1.1"
# Windows on Python 3.8+ uses ProactorEventLoop, which is not compatible with

View File

@ -1,6 +1,7 @@
import datetime
import logging
logger = logging.getLogger(__name__)
class AccessLogGenerator:
"""
Object that implements the Daphne "action logger" internal interface in
@ -8,7 +9,7 @@ class AccessLogGenerator:
"""
def __init__(self, stream):
self.stream = stream
self.stream = logger
def __call__(self, protocol, action, details):
"""
@ -56,7 +57,16 @@ class AccessLogGenerator:
Writes an NCSA-style entry to the log file (some liberty is taken with
what the entries are for non-HTTP)
"""
self.stream.write(
atoms = {
"host": host,
"time": date.strftime("%d/%b/%Y:%H:%M:%S"),
"request": request,
"status": status,
"size": length,
"ident": ident,
"user": user
}
self.stream.info(
'%s %s %s [%s] "%s" %s %s\n'
% (
host,
@ -66,5 +76,6 @@ class AccessLogGenerator:
request,
status or "-",
length or "-",
)
),
extra=atoms
)

View File

@ -10,11 +10,10 @@ with open(readme_path) as fp:
long_description = fp.read()
setup(
name="daphne",
name="ocp-daphne",
version=__version__,
url="https://github.com/django/daphne",
author="Django Software Foundation",
author_email="foundation@djangoproject.com",
author="Aryan Kapoor",
author_email="pro.akapoor@gmail.com",
description="Django ASGI (HTTP/WebSocket) server",
long_description=long_description,
license="BSD",