mirror of
https://github.com/django/daphne.git
synced 2025-07-14 18:02:17 +03:00
add logging
This commit is contained in:
parent
36ce9fd1ed
commit
107475005f
|
@ -1,6 +1,6 @@
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
__version__ = "3.0.2"
|
__version__ = "1.1.1"
|
||||||
|
|
||||||
|
|
||||||
# Windows on Python 3.8+ uses ProactorEventLoop, which is not compatible with
|
# Windows on Python 3.8+ uses ProactorEventLoop, which is not compatible with
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
import datetime
|
import datetime
|
||||||
|
import logging
|
||||||
|
|
||||||
|
logger = logging.getLogger(__name__)
|
||||||
class AccessLogGenerator:
|
class AccessLogGenerator:
|
||||||
"""
|
"""
|
||||||
Object that implements the Daphne "action logger" internal interface in
|
Object that implements the Daphne "action logger" internal interface in
|
||||||
|
@ -8,7 +9,7 @@ class AccessLogGenerator:
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def __init__(self, stream):
|
def __init__(self, stream):
|
||||||
self.stream = stream
|
self.stream = logger
|
||||||
|
|
||||||
def __call__(self, protocol, action, details):
|
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
|
Writes an NCSA-style entry to the log file (some liberty is taken with
|
||||||
what the entries are for non-HTTP)
|
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'
|
'%s %s %s [%s] "%s" %s %s\n'
|
||||||
% (
|
% (
|
||||||
host,
|
host,
|
||||||
|
@ -66,5 +76,6 @@ class AccessLogGenerator:
|
||||||
request,
|
request,
|
||||||
status or "-",
|
status or "-",
|
||||||
length 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()
|
long_description = fp.read()
|
||||||
|
|
||||||
setup(
|
setup(
|
||||||
name="daphne",
|
name="ocp-daphne",
|
||||||
version=__version__,
|
version=__version__,
|
||||||
url="https://github.com/django/daphne",
|
author="Aryan Kapoor",
|
||||||
author="Django Software Foundation",
|
author_email="pro.akapoor@gmail.com",
|
||||||
author_email="foundation@djangoproject.com",
|
|
||||||
description="Django ASGI (HTTP/WebSocket) server",
|
description="Django ASGI (HTTP/WebSocket) server",
|
||||||
long_description=long_description,
|
long_description=long_description,
|
||||||
license="BSD",
|
license="BSD",
|
||||||
|
|
Loading…
Reference in New Issue
Block a user