This commit is contained in:
parent
2bf8d6b573
commit
bb62f5ce84
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
@ -2,22 +2,16 @@ import logging,os,time
|
|||
|
||||
class log_message:
|
||||
def __init__(self,title):
|
||||
# time
|
||||
self.day=time.strftime("%Y%m%d",time.localtime(time.time()))
|
||||
#创建一个logger
|
||||
self.logger=logging.getLogger(title)
|
||||
self.logger.setLevel(logging.INFO)
|
||||
#创建Heandler 用于写入文件
|
||||
self.logfile=logging.FileHandler(r'C:\Users\Administrator\Desktop\te_blogf\lo\%s.log'%self.day)
|
||||
self.logfile.setLevel(logging.INFO)
|
||||
#创建Heandler 用于显示控制台
|
||||
self.control=logging.StreamHandler()
|
||||
self.control.setLevel(logging.INFO)
|
||||
#定义输出格式
|
||||
self.formatter=logging.Formatter("%(asctime)s - %(name)s - %(levelname)s - %(message)s")
|
||||
self.logfile.setFormatter(self.formatter)
|
||||
self.control.setFormatter(self.formatter)
|
||||
#给logger添加handler
|
||||
self.logger.addHandler(self.logfile)
|
||||
self.logger.addHandler(self.control)
|
||||
def debug_log(self,message):
|
||||
|
|
|
@ -51,5 +51,4 @@ def create_report_sendemali(now):
|
|||
print('send is ok!!!')
|
||||
if __name__=="__main__":
|
||||
now=create_report()
|
||||
print(now)
|
||||
create_report_sendemali(now)
|
Loading…
Reference in New Issue