feat chat robot 接口迁移

This commit is contained in:
zhouchengrong
2024-05-29 11:12:59 +08:00
parent a9dcd444c8
commit 13fec64125
23 changed files with 1139 additions and 1 deletions

View File

@@ -0,0 +1,26 @@
import logging
from logging import handlers
class Logger(object):
level_relations = {
'debug': logging.DEBUG,
'info': logging.INFO,
'warning': logging.WARNING,
'error': logging.ERROR,
'crit': logging.CRITICAL
}
def __init__(self, filename, level='info', when='D', backCount=3,
fmt='%(asctime)s - %(pathname)s[line:%(lineno)d] - %(levelname)s: %(message)s'):
self.logger = logging.getLogger(filename)
format_str = logging.Formatter(fmt) # set log format
self.logger.setLevel(self.level_relations.get(level)) # set log level
sh = logging.StreamHandler() # output to terminal
sh.setFormatter(format_str) # set format for terminal log
th = handlers.TimedRotatingFileHandler(filename=filename, when=when, backupCount=backCount,
encoding='utf-8') # log into file
th.setFormatter(format_str) # set format for file log
self.logger.addHandler(sh) # output to terminal
self.logger.addHandler(th) # output to file