提交 28aebf77 编写于 作者: W wenzhouwww@live.cn

test : Add timestamp to logger when in debug mode

上级 08316af0
...@@ -4,7 +4,8 @@ import logging ...@@ -4,7 +4,8 @@ import logging
import os import os
import sys import sys
from typing import Optional from typing import Optional
import time , datetime
from datetime import datetime
import taos import taos
...@@ -64,22 +65,26 @@ class Logging: ...@@ -64,22 +65,26 @@ class Logging:
# global logger # global logger
cls.logger = MyLoggingAdapter(_logger, {}) cls.logger = MyLoggingAdapter(_logger, {})
cls.logger.setLevel(logging.DEBUG if debugMode else logging.INFO) # default seems to be INFO cls.logger.setLevel(logging.DEBUG if debugMode else logging.INFO) # default seems to be INFO
@classmethod @classmethod
def info(cls, msg): def info(cls, msg):
cls.logger.info(msg) date = datetime.utcnow().strftime('%Y-%m-%d %H:%M:%S.%f')[:-1]
cls.logger.info("[time]: " + date +" [msg]: "+ msg)
@classmethod @classmethod
def debug(cls, msg): def debug(cls, msg):
cls.logger.debug(msg) date = datetime.utcnow().strftime('%Y-%m-%d %H:%M:%S.%f')[:-1]
cls.logger.debug("[time]: " + date +" [msg]: "+ msg)
@classmethod @classmethod
def warning(cls, msg): def warning(cls, msg):
cls.logger.warning(msg) date = datetime.utcnow().strftime('%Y-%m-%d %H:%M:%S.%f')[:-1]
cls.logger.warning("[time]: " + date +" [msg]: "+ msg)
@classmethod @classmethod
def error(cls, msg): def error(cls, msg):
cls.logger.error(msg) date = datetime.utcnow().strftime('%Y-%m-%d %H:%M:%S.%f')[:-1]
cls.logger.error("[time]: " + date +" [msg]: "+ msg)
class Status: class Status:
STATUS_EMPTY = 99 STATUS_EMPTY = 99
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册