未验证 提交 75d7dd33 编写于 作者: H Hui Li 提交者: GitHub

Merge pull request #14733 from taosdata/test/crash_gen_enh

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