mirror of
https://github.com/django/daphne.git
synced 2025-04-20 00:32:09 +03:00
add logging
This commit is contained in:
parent
36ce9fd1ed
commit
107475005f
|
@ -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
|
||||
|
|
|
@ -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
|
||||
)
|
||||
|
|
7
setup.py
7
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",
|
||||
|
|
Loading…
Reference in New Issue
Block a user