From 107475005f54457c9f414033288009c2424bc36e Mon Sep 17 00:00:00 2001 From: Aryan Kapoor Date: Fri, 30 Jul 2021 10:30:16 +0530 Subject: [PATCH] add logging --- daphne/__init__.py | 2 +- daphne/access.py | 19 +++++++++++++++---- setup.py | 7 +++---- 3 files changed, 19 insertions(+), 9 deletions(-) diff --git a/daphne/__init__.py b/daphne/__init__.py index 530cbd0..fa8ec01 100755 --- a/daphne/__init__.py +++ b/daphne/__init__.py @@ -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 diff --git a/daphne/access.py b/daphne/access.py index e18138a..32c8b58 100644 --- a/daphne/access.py +++ b/daphne/access.py @@ -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 ) diff --git a/setup.py b/setup.py index af3b3b9..46b3e4a 100755 --- a/setup.py +++ b/setup.py @@ -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",