Re: [Kimchi-devel] [PATCH] [Wok 2/2] Log time in ISO format

The same I commented on patch 1. Update the API.md as this patch also changed the API and add/change the test cases to confirm it keeps working. On 06/03/2016 06:40 PM, Lucio Correia wrote:
Signed-off-by: Lucio Correia <luciojhc@linux.vnet.ibm.com> --- src/wok/reqlogger.py | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-)
diff --git a/src/wok/reqlogger.py b/src/wok/reqlogger.py index 2ec62b8..6f32c44 100644 --- a/src/wok/reqlogger.py +++ b/src/wok/reqlogger.py @@ -23,9 +23,9 @@ import json import logging import logging.handlers import os.path +import time
from cherrypy.process.plugins import BackgroundTask -from datetime import datetime from tempfile import NamedTemporaryFile
from wok.config import config, get_log_download_path @@ -37,11 +37,12 @@ from wok.utils import ascii_dict, remove_old_files FILTER_FIELDS = ['app', 'date', 'download', 'ip', 'req', 'user', 'time'] LOG_DOWNLOAD_URI = "/data/logs/%s" LOG_DOWNLOAD_TIMEOUT = 6 -LOG_FORMAT = "[%(date)s %(time)s] %(req)-6s %(app)-11s %(ip)-15s %(user)s: " \ - "%(message)s\n" +LOG_FORMAT = "[%(date)s %(time)s %(zone)s] %(req)-6s %(app)-11s %(ip)-15s " \ + "%(user)s: %(message)s\n" RECORD_TEMPLATE_DICT = { 'date': '', 'time': '', + 'zone': '', 'req': '', 'app': '', 'ip': '', @@ -49,6 +50,9 @@ RECORD_TEMPLATE_DICT = { 'message': '', } SECONDS_PER_HOUR = 360 +TS_DATE_FORMAT = "%Y-%m-%d" +TS_TIME_FORMAT = "%H:%M:%S" +TS_ZONE_FORMAT = "%Z"
# Log handler setup REQUEST_LOG_FILE = "wok-req.log" @@ -180,10 +184,11 @@ class RequestRecord(object): self.message = message self.kwargs = kwargs
- # register timestamp - timestamp = datetime.today() - self.kwargs['date'] = timestamp.strftime('%Y-%m-%d') - self.kwargs['time'] = timestamp.strftime('%H:%M:%S') + # register timestamp in local time + timestamp = time.localtime() + self.kwargs['date'] = time.strftime(TS_DATE_FORMAT, timestamp) + self.kwargs['time'] = time.strftime(TS_TIME_FORMAT, timestamp) + self.kwargs['zone'] = time.strftime(TS_ZONE_FORMAT, timestamp)
def __str__(self): info = json.JSONEncoder().encode(self.kwargs)

On 07-06-2016 22:45, Aline Manera wrote:
The same I commented on patch 1. Update the API.md as this patch also changed the API and add/change the test cases to confirm it keeps working.
This patch does not change API, since 'time' is not documented as a search field in logs.md. I also think we should remove "time" field from "Advanced Search" in UI, since it can be more effectively done by using Filter option in main results page. -- Lucio Correia Software Engineer IBM LTC Brazil

On 06/09/2016 11:37 AM, Lucio Correia wrote:
On 07-06-2016 22:45, Aline Manera wrote:
The same I commented on patch 1. Update the API.md as this patch also changed the API and add/change the test cases to confirm it keeps working.
This patch does not change API, since 'time' is not documented as a search field in logs.md. I also think we should remove "time" field from "Advanced Search" in UI, since it can be more effectively done by using Filter option in main results page.
ACK,
participants (2)
-
Aline Manera
-
Lucio Correia