Commit 8ed61b12 authored by i317280's avatar i317280

feat: record release

parent 39953fd1
...@@ -99,18 +99,19 @@ class ServerReplayRecorder(ReplayRecorder): ...@@ -99,18 +99,19 @@ class ServerReplayRecorder(ReplayRecorder):
:return: :return:
""" """
# Todo: <liuzheng712@gmail.com> # Todo: <liuzheng712@gmail.com>
self.file.write(str({'data': data['data'], 't': data['timestamp'] - self.starttime})) if len(data['data']) > 0:
self.file.write(',') self.file.write(
'"' + str(data['timestamp'] - self.starttime) + '":"' + data['data'].decode('utf-8', 'replace') + '",')
def session_start(self, session_id): def session_start(self, session_id):
self.starttime = time.time() self.starttime = time.time()
self.file = open(os.path.join( self.file = open(os.path.join(
self.app.config['LOG_DIR'], session_id + '.replay' self.app.config['LOG_DIR'], session_id + '.replay'
), 'a') ), 'a')
self.file.write('[') self.file.write('{')
def session_end(self, session_id): def session_end(self, session_id):
self.file.write(']') self.file.write('}')
self.file.close() self.file.close()
def push_to_server(self): def push_to_server(self):
......
...@@ -121,7 +121,7 @@ class Session: ...@@ -121,7 +121,7 @@ class Session:
events = self.sel.select() events = self.sel.select()
for sock in [key.fileobj for key, _ in events]: for sock in [key.fileobj for key, _ in events]:
data = sock.recv(BUF_SIZE) data = sock.recv(BUF_SIZE)
self.put_replay(data) # self.put_replay(data)
if sock == self.server: if sock == self.server:
if len(data) == 0: if len(data) == 0:
msg = "Server close the connection" msg = "Server close the connection"
......
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