这一部分实现比较简单,直接上代码:
1 import logging 2 3 class Logger(): 4 def __init__(self,content,*raw): 5 self.content = content 6 7 def log(self): 8 logging.basicConfig(level=logging.DEBUG, 9 format=‘%(asctime)s %(filename)s[line:%(lineno)d] %(levelname)s %(message)s‘, 10 datefmt=‘%a, %d %b %Y %H:%M:%S‘, 11 filename=‘mylog.log‘, 12 filemode=‘w‘) 13 logging.info(self.content)
打印出来的效果把代码拷出试一下就知道了