This commit is contained in:
yumoqing 2024-11-23 13:34:55 +08:00
parent d0bf300975
commit 7140863800

View File

@ -1,5 +1,6 @@
import sys
import codecs
from traceback import format_exc
from appPublic.timeUtils import timestampstr
from appPublic.Singleton import SingletonDecorator
import inspect
@ -15,8 +16,9 @@ def my_function():
@SingletonDecorator
class MyLogger:
levels={
"debug":5,
"client":7,
"info":6,
"debug":5,
"warning":4,
"error":3,
"exception":2,
@ -63,6 +65,11 @@ class MyLogger:
self.logger.flush()
self.close_logger()
def client(message):
frame_info = inspect.currentframe()
logger = MyLogger('Test')
logger.log('client', message, frame_info)
def info(message):
frame_info = inspect.currentframe()
logger = MyLogger('Test')
@ -90,6 +97,8 @@ def critical(message):
def exception(message):
frame_info = inspect.currentframe()
tb_msg = format_exc()
msg = f'{message}\n{tb_msg}'
logger = MyLogger('exception')
logger.log('exception', message, frame_info)
logger.log('exception', msg, frame_info)