File tree Expand file tree Collapse file tree 2 files changed +11
-8
lines changed Expand file tree Collapse file tree 2 files changed +11
-8
lines changed Original file line number Diff line number Diff line change 3
3
4
4
logger = logging .getLogger (__name__ )
5
5
6
+
6
7
class AccessLogGenerator :
7
8
"""
8
9
Object that implements the Daphne "action logger" internal interface in
@@ -13,9 +14,11 @@ def __init__(self, stream):
13
14
if stream :
14
15
logger .propagate = False
15
16
handler = logging .StreamHandler (stream )
16
- formatter = logging .Formatter ('%(host)s %(ident)s %(user)s [%(asctime)s] "%{request} %(message)s" '
17
- '%(status)s %(length)s'
18
- "%d/%b/%Y:%H:%M:%S" )
17
+ formatter = logging .Formatter (
18
+ '%(host)s %(ident)s %(user)s [%(asctime)s] "%{request} %(message)s" '
19
+ "%(status)s %(length)s"
20
+ "%d/%b/%Y:%H:%M:%S"
21
+ )
19
22
handler .setFormatter (fmt = formatter )
20
23
logger .addHandler (handler )
21
24
else :
@@ -78,5 +81,5 @@ def write_entry(
78
81
"user" : user or "-" ,
79
82
"status" : status or "-" ,
80
83
"length" : length or "-" ,
81
- }
84
+ },
82
85
)
Original file line number Diff line number Diff line change @@ -228,7 +228,9 @@ def run(self, args):
228
228
elif args .verbosity >= 1 :
229
229
access_log_stream = sys .stdout
230
230
231
- access_logger = AccessLogGenerator (access_log_stream ) if access_log_stream else None
231
+ access_logger = (
232
+ AccessLogGenerator (access_log_stream ) if access_log_stream else None
233
+ )
232
234
233
235
# Import application
234
236
sys .path .insert (0 , "." )
@@ -272,9 +274,7 @@ def run(self, args):
272
274
websocket_connect_timeout = args .websocket_connect_timeout ,
273
275
websocket_handshake_timeout = args .websocket_connect_timeout ,
274
276
application_close_timeout = args .application_close_timeout ,
275
- action_logger = access_logger
276
- if access_log_stream
277
- else None ,
277
+ action_logger = access_logger if access_log_stream else None ,
278
278
root_path = args .root_path ,
279
279
verbosity = args .verbosity ,
280
280
proxy_forwarded_address_header = self ._get_forwarded_host (args = args ),
You can’t perform that action at this time.
0 commit comments