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 os
|
||||||
import sys
|
import sys
|
||||||
from typing import Optional
|
from typing import Optional
|
||||||
|
import time , datetime
|
||||||
|
from datetime import datetime
|
||||||
import taos
|
import taos
|
||||||
|
|
||||||
|
|
||||||
|
@ -43,6 +44,10 @@ class MyLoggingAdapter(logging.LoggerAdapter):
|
||||||
class Logging:
|
class Logging:
|
||||||
logger = None # type: Optional[MyLoggingAdapter]
|
logger = None # type: Optional[MyLoggingAdapter]
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def _get_datetime(cls):
|
||||||
|
return datetime.utcnow().strftime('%Y-%m-%d %H:%M:%S.%f')[:-1]
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def getLogger(cls):
|
def getLogger(cls):
|
||||||
return cls.logger
|
return cls.logger
|
||||||
|
@ -67,19 +72,19 @@ class Logging:
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def info(cls, msg):
|
def info(cls, msg):
|
||||||
cls.logger.info(msg)
|
cls.logger.info("[time]: " + cls._get_datetime() +" [msg]: "+ msg)
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def debug(cls, msg):
|
def debug(cls, msg):
|
||||||
cls.logger.debug(msg)
|
cls.logger.debug("[time]: " + cls._get_datetime() +" [msg]: "+ msg)
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def warning(cls, msg):
|
def warning(cls, msg):
|
||||||
cls.logger.warning(msg)
|
cls.logger.warning("[time]: " + cls._get_datetime() +" [msg]: "+ msg)
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def error(cls, msg):
|
def error(cls, msg):
|
||||||
cls.logger.error(msg)
|
cls.logger.error("[time]: " + cls._get_datetime() +" [msg]: "+ msg)
|
||||||
|
|
||||||
class Status:
|
class Status:
|
||||||
STATUS_EMPTY = 99
|
STATUS_EMPTY = 99
|
||||||
|
|
Loading…
Reference in New Issue