-
Notifications
You must be signed in to change notification settings - Fork 108
Expand file tree
/
Copy pathfile.py
More file actions
39 lines (27 loc) · 1.03 KB
/
file.py
File metadata and controls
39 lines (27 loc) · 1.03 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
import logging
from plugins.logger.interface import LogInterface
class FileLog(LogInterface):
def __init__(self):
# 创建 logger 对象
self.logger = logging.getLogger(__name__)
self.logger.setLevel(logging.DEBUG)
# 创建 FileHandler 对象
file_handler = logging.FileHandler('debug.log')
file_handler.setLevel(logging.DEBUG)
# 创建 Formatter 对象
formatter = logging.Formatter('%(asctime)s - %(levelname)s - %(message)s')
file_handler.setFormatter(formatter)
# 添加 Formatter 对象到 FileHandler 对象中
file_handler.setFormatter(formatter)
# 添加 FileHandler 对象到 logger 对象中
self.logger.addHandler(file_handler)
def info(self, arg):
self.logger.info(arg)
def debug(self, arg):
self.logger.debug(arg)
def warning(self, arg):
self.logger.warning(arg)
def error(self, arg):
self.logger.error(arg)
def critical(self, arg):
self.logger.critical(arg)