From 714086380080139251db2dc87e779b47116dbad5 Mon Sep 17 00:00:00 2001 From: yumoqing Date: Sat, 23 Nov 2024 13:34:55 +0800 Subject: [PATCH] bugfix --- appPublic/log.py | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/appPublic/log.py b/appPublic/log.py index c4395a7..5cb384b 100644 --- a/appPublic/log.py +++ b/appPublic/log.py @@ -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)