Merge pull request #14733 from taosdata/test/crash_gen_enh
test : Add timestamp to the logger when it in the debug mode
This commit is contained in:
commit
75d7dd3380
|
@ -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
|
||||
|
@ -67,19 +72,19 @@ class Logging:
|
|||
|
||||
@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
|
||||
|
|
Loading…
Reference in New Issue