From 9ac74220d444bab1578f49ab5ed1b533771b17d1 Mon Sep 17 00:00:00 2001 From: Jonathan Baecker Date: Tue, 12 May 2020 13:07:42 +0200 Subject: [PATCH] get log from given date, fix #6 --- ffplayout/apps/api_player/utils.py | 9 +++++++-- ffplayout/apps/api_player/views.py | 6 ++++-- ffplayout/frontend/assets/scss/globals.scss | 12 ++++++++++++ ffplayout/frontend/pages/logging.vue | 18 ++++++++++++++++-- ffplayout/frontend/pages/player.vue | 10 ---------- 5 files changed, 39 insertions(+), 16 deletions(-) diff --git a/ffplayout/apps/api_player/utils.py b/ffplayout/apps/api_player/utils.py index 4473dd92..fbe1b321 100644 --- a/ffplayout/apps/api_player/utils.py +++ b/ffplayout/apps/api_player/utils.py @@ -1,5 +1,6 @@ import json import os +from datetime import date from platform import uname from subprocess import PIPE, STDOUT, run from time import sleep @@ -50,10 +51,14 @@ def write_json(data): json.dump(data, outfile, indent=4) -def read_log(type): +def read_log(type, _date): config = read_yaml() log_path = config['logging']['log_path'] - log_file = os.path.join(log_path, '{}.log'.format(type)) + + if _date == date.today(): + log_file = os.path.join(log_path, '{}.log'.format(type)) + else: + log_file = os.path.join(log_path, '{}.log.{}'.format(type, _date)) if os.path.isfile(log_file): with open(log_file, 'r') as log: diff --git a/ffplayout/apps/api_player/views.py b/ffplayout/apps/api_player/views.py index c4dc08c4..441af673 100644 --- a/ffplayout/apps/api_player/views.py +++ b/ffplayout/apps/api_player/views.py @@ -129,9 +129,11 @@ class SystemCtl(APIView): class LogReader(APIView): def get(self, request, *args, **kwargs): - if 'type' in request.GET.dict(): + if 'type' in request.GET.dict() and 'date' in request.GET.dict(): type = request.GET.dict()['type'] - log = read_log(type) + _date = request.GET.dict()['date'] + + log = read_log(type, _date) if log: return Response({'log': log}) diff --git a/ffplayout/frontend/assets/scss/globals.scss b/ffplayout/frontend/assets/scss/globals.scss index 35cfefad..a1a7e5b6 100644 --- a/ffplayout/frontend/assets/scss/globals.scss +++ b/ffplayout/frontend/assets/scss/globals.scss @@ -9,6 +9,18 @@ font-style: normal; } +.date-row { + height: 40px; + width: 100%; + padding-top: 5px; + margin: 0; +} + +.date-div { + width: 250px; + float: right; +} + .breadcrumb { margin-bottom: .2em; } diff --git a/ffplayout/frontend/pages/logging.vue b/ffplayout/frontend/pages/logging.vue index fe734a49..fc39d135 100644 --- a/ffplayout/frontend/pages/logging.vue +++ b/ffplayout/frontend/pages/logging.vue @@ -1,6 +1,11 @@