This commit is contained in:
yumoqing 2023-06-08 11:22:58 +08:00
parent 827f27738f
commit 97e2137e33

View File

@ -14,12 +14,15 @@ logfile = -1
g_levelname='info' g_levelname='info'
level = levels.get('info') level = levels.get('info')
def create_logger(name, formater=defaultfmt, levelname=g_levelname, file=None): def create_logger(name, formater=defaultfmt, levelname=None, file=None):
global logfile, level global logfile, level
if logfile == -1: if logfile == -1:
logfile = file logfile = file
ret = logging.getLogger(name) ret = logging.getLogger(name)
if levelname:
g_levelname = levelname g_levelname = levelname
else:
levelname = g_levelname
level = levels.get(levelname, levels.get('info')) level = levels.get(levelname, levels.get('info'))
ret.setLevel(level) ret.setLevel(level)
format = logging.Formatter(formater) format = logging.Formatter(formater)