Commit 5845a0b9 authored by Amos Latteier's avatar Amos Latteier

Changed tabs to spaces and added a flush to log writing.

parent 0dc69b1e
......@@ -86,48 +86,47 @@
import time, thread
class DebugLogger:
"""
Logs debugging information about how ZServer is handling requests
and responses. This log can be used to help locate troublesome requests.
The format is:
<code> <request id> <time> <data>
where:
'code' is B for begin, I for received input, A for received output,
E for sent output.
'request id' is a unique request id.
'time' is the time in GMT ISO format.
'data' is the HTTP method and the PATH INFO for B, the size of the input
for I, the HTTP status code and the size of the output for A, or
nothing for E.
Note: This facility will be probably be adapted to the zLOG framework.
"""
def __init__(self, filename):
self.file=open(filename, 'a+b')
l=thread.allocate_lock()
self._acquire=l.acquire
self._release=l.release
def log(self, code, request_id, data=''):
self._acquire()
try:
t=time.strftime('%Y-%m-%dT%H:%M:%S', time.gmtime(time.time()))
self.file.write(
'%s %s %s %s\n' % (code, request_id, t, data)
)
finally:
self._release()
"""
Logs debugging information about how ZServer is handling requests
and responses. This log can be used to help locate troublesome requests.
The format is:
<code> <request id> <time> <data>
where:
'code' is B for begin, I for received input, A for received output,
E for sent output.
'request id' is a unique request id.
'time' is the time in GMT ISO format.
'data' is the HTTP method and the PATH INFO for B, the size of the input
for I, the HTTP status code and the size of the output for A, or
nothing for E.
Note: This facility will be probably be adapted to the zLOG framework.
"""
def __init__(self, filename):
self.file=open(filename, 'a+b')
l=thread.allocate_lock()
self._acquire=l.acquire
self._release=l.release
def log(self, code, request_id, data=''):
self._acquire()
try:
t=time.strftime('%Y-%m-%dT%H:%M:%S', time.gmtime(time.time()))
self.file.write(
'%s %s %s %s\n' % (code, request_id, t, data)
)
self.file.flush()
finally:
self._release()
def log(*args): pass
\ No newline at end of file
......@@ -86,48 +86,47 @@
import time, thread
class DebugLogger:
"""
Logs debugging information about how ZServer is handling requests
and responses. This log can be used to help locate troublesome requests.
The format is:
<code> <request id> <time> <data>
where:
'code' is B for begin, I for received input, A for received output,
E for sent output.
'request id' is a unique request id.
'time' is the time in GMT ISO format.
'data' is the HTTP method and the PATH INFO for B, the size of the input
for I, the HTTP status code and the size of the output for A, or
nothing for E.
Note: This facility will be probably be adapted to the zLOG framework.
"""
def __init__(self, filename):
self.file=open(filename, 'a+b')
l=thread.allocate_lock()
self._acquire=l.acquire
self._release=l.release
def log(self, code, request_id, data=''):
self._acquire()
try:
t=time.strftime('%Y-%m-%dT%H:%M:%S', time.gmtime(time.time()))
self.file.write(
'%s %s %s %s\n' % (code, request_id, t, data)
)
finally:
self._release()
"""
Logs debugging information about how ZServer is handling requests
and responses. This log can be used to help locate troublesome requests.
The format is:
<code> <request id> <time> <data>
where:
'code' is B for begin, I for received input, A for received output,
E for sent output.
'request id' is a unique request id.
'time' is the time in GMT ISO format.
'data' is the HTTP method and the PATH INFO for B, the size of the input
for I, the HTTP status code and the size of the output for A, or
nothing for E.
Note: This facility will be probably be adapted to the zLOG framework.
"""
def __init__(self, filename):
self.file=open(filename, 'a+b')
l=thread.allocate_lock()
self._acquire=l.acquire
self._release=l.release
def log(self, code, request_id, data=''):
self._acquire()
try:
t=time.strftime('%Y-%m-%dT%H:%M:%S', time.gmtime(time.time()))
self.file.write(
'%s %s %s %s\n' % (code, request_id, t, data)
)
self.file.flush()
finally:
self._release()
def log(*args): pass
\ No newline at end of file
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment