diff --git a/logtailer.ini b/logtailer.ini index 7a9ad3f..0da4bf6 100644 --- a/logtailer.ini +++ b/logtailer.ini @@ -2,6 +2,12 @@ Host=0.0.0.0 Port=5678 +# This defines the maximum amount of loglines to be sent on initial opening of the dashboard +MaxLines=500 + +# Keep this parameter synchrone to Filerotate in YSFReflector.ini - if 0 then False, if 1 then True +Filerotate=True + [MMDVMHost] Logdir=/mnt/ramdisk/ Prefix=MMDVM diff --git a/logtailer.py b/logtailer.py index 8b11573..2ba604c 100644 --- a/logtailer.py +++ b/logtailer.py @@ -81,7 +81,7 @@ async def view_log(websocket, path): raise ValueError('Fail to parse URL', format(path)) path = os.path.abspath(parse_result.path) - now = datetime.datetime.now() + now = datetime.datetime.now(datetime.timezone.utc) year = str(now.year) month = str(now.month) if len(month) == 1: @@ -92,9 +92,15 @@ async def view_log(websocket, path): file_path = "" if path == "/MMDVM": - file_path = config['MMDVMHost']['Logdir']+config['MMDVMHost']['Prefix']+"-"+year+"-"+month+"-"+day+".log" + if config['DEFAULT']['Filerotate'] == "True": + file_path = config['MMDVMHost']['Logdir']+config['MMDVMHost']['Prefix']+"-"+year+"-"+month+"-"+day+".log" + else: + file_path = config['MMDVMHost']['Logdir']+config['MMDVMHost']['Prefix']+".log" elif path == "/DAPNET": - file_path = config['DAPNETGateway']['Logdir']+config['DAPNETGateway']['Prefix']+"-"+year+"-"+month+"-"+day+".log" + if config['DEFAULT']['Filerotate'] == "True": + file_path = config['DAPNETGateway']['Logdir']+config['DAPNETGateway']['Prefix']+"-"+year+"-"+month+"-"+day+".log" + else: + file_path = config['DAPNETGateway']['Logdir']+config['DAPNETGateway']['Prefix']+".log" if path == "/MMDVM" or path == "/DAPNET": logging.info(file_path) @@ -102,7 +108,7 @@ async def view_log(websocket, path): raise ValueError('File not found', format(file_path)) with open(file_path, newline = '\n', encoding="utf8", errors='ignore') as f: - content = ''.join(deque(f)) + content = ''.join(deque(f, 2)) content = conv.convert(content, full=False) lines = content.split("\n") for line in lines: