diff --git a/pkg/workloads/cortex/lib/log.py b/pkg/workloads/cortex/lib/log.py index ce8daa2322..e83e8feab0 100644 --- a/pkg/workloads/cortex/lib/log.py +++ b/pkg/workloads/cortex/lib/log.py @@ -14,10 +14,29 @@ import logging from cortex.lib import stringify +import datetime as dt + + +class MyFormatter(logging.Formatter): + converter = dt.datetime.fromtimestamp + + def formatTime(self, record, datefmt=None): + ct = self.converter(record.created) + if datefmt: + s = ct.strftime(datefmt) + else: + t = ct.strftime("%Y-%m-%d %H:%M:%S") + s = "%s,%03d" % (t, record.msecs) + return s + logger = logging.getLogger("cortex") handler = logging.StreamHandler() -handler.setFormatter(logging.Formatter(logging.BASIC_FORMAT, None)) +formatter = MyFormatter( + fmt="%(asctime)s:%(name)s:%(levelname)s:%(message)s", datefmt="%Y-%m-%d,%H:%M:%S.%f" +) +handler.setFormatter(formatter) + logger.addHandler(handler) logger.setLevel(logging.DEBUG) diff --git a/pkg/workloads/cortex/onnx_serve/api.py b/pkg/workloads/cortex/onnx_serve/api.py index 067288a2c5..fa6c714e3f 100644 --- a/pkg/workloads/cortex/onnx_serve/api.py +++ b/pkg/workloads/cortex/onnx_serve/api.py @@ -79,7 +79,7 @@ def after_request(response): if request.path != "/{}/{}".format(ctx.app["name"], api["name"]): return response - logger.info("[%s] %s", util.now_timestamp_rfc_3339(), response.status) + logger.info(response.status) predictions = None if "predictions" in g: diff --git a/pkg/workloads/cortex/tf_api/api.py b/pkg/workloads/cortex/tf_api/api.py index e6b35c016e..13a1dff5dd 100644 --- a/pkg/workloads/cortex/tf_api/api.py +++ b/pkg/workloads/cortex/tf_api/api.py @@ -105,7 +105,7 @@ def after_request(response): if request.path != "/{}/{}".format(ctx.app["name"], api["name"]): return response - logger.info("[%s] %s", util.now_timestamp_rfc_3339(), response.status) + logger.info(response.status) predictions = None if "predictions" in g: