1
0
mirror of https://github.com/gsi-upm/soil synced 2024-11-22 19:22:29 +00:00

Logs fixed

This commit is contained in:
Tasio Mendez 2018-02-02 16:12:43 +01:00
parent 20aea9da33
commit c2d1e0d4f2
3 changed files with 8 additions and 7 deletions

View File

@ -1,6 +1,6 @@
name: ControlModelM2_sim name: ControlModelM2_sim
max_time: 15 max_time: 60
num_trials: 1 num_trials: 4
network_params: network_params:
generator: barabasi_albert_graph generator: barabasi_albert_graph
n: 100 n: 100

View File

@ -9,11 +9,10 @@ import webbrowser
import yaml import yaml
import logging import logging
import logging
import threading import threading
import io import io
import networkx as nx import networkx as nx
from datetime import timedelta from time import sleep
from contextlib import contextmanager from contextlib import contextmanager
logger = logging.getLogger(__name__) logger = logging.getLogger(__name__)
@ -128,12 +127,13 @@ class SocketHandler(tornado.websocket.WebSocketHandler):
def update_logging(self): def update_logging(self):
try: try:
if (not self.log_capture_string.closed and self.log_capture_string.getvalue()): if (not self.log_capture_string.closed and self.log_capture_string.getvalue()):
self.send_log('INFO.soil', self.log_capture_string.getvalue()) for i in range(len(self.log_capture_string.getvalue().split('\n')) - 1):
self.send_log('INFO.soil', self.log_capture_string.getvalue().split('\n')[i])
self.log_capture_string.truncate(0) self.log_capture_string.truncate(0)
self.log_capture_string.seek(0) self.log_capture_string.seek(0)
finally: finally:
if self.capture_logging: if self.capture_logging:
thread = threading.Timer(0.001, self.update_logging) thread = threading.Timer(0.01, self.update_logging)
thread.start() thread.start()
def on_close(self): def on_close(self):
@ -169,6 +169,7 @@ class SocketHandler(tornado.websocket.WebSocketHandler):
self.update_logging() self.update_logging()
yield self.capture_logging yield self.capture_logging
sleep(0.2)
self.log_capture_string.close() self.log_capture_string.close()
self.logger_application.removeHandler(ch) self.logger_application.removeHandler(ch)
self.capture_logging = False self.capture_logging = False

View File

@ -58,7 +58,7 @@ ws.onmessage = function(message) {
case 'log': case 'log':
$('.console').append('$ ' + msg['logger'] + ': ' + msg['logging'] + '<br/>'); $('.console').append('$ ' + msg['logger'] + ': ' + msg['logging'] + '<br/>');
$('.console').animate({ scrollTop: $('.console')[0].scrollHeight }, 'slow'); $('.console').animate({ scrollTop: $('.console')[0].scrollHeight }, 'fast');
break; break;
default: default: