MCPcopy Create free account
hub / github.com/answerlink/IntelliQ / setup_logging

Function setup_logging

config/log_config.py:4–19  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

2
3
4def setup_logging():
5 # 设置日志的配置
6 logging.basicConfig(
7 level=logging.DEBUG, # 设置日志级别为 DEBUG,也可以设置为 INFO, WARNING, ERROR, CRITICAL
8 format='%(asctime)s - %(name)s - %(levelname)s - %(message)s', # 设置日志格式
9 filename='app.log', # 日志输出到文件,不设置这个参数则输出到标准输出(控制台)
10 filemode='a' # 'w' 表示写模式,'a' 表示追加模式
11 )
12
13 # 如果还想要将日志输出到控制台,可以添加一个 StreamHandler
14 console_handler = logging.StreamHandler()
15 console_handler.setLevel(logging.INFO) # 设置控制台的日志级别
16 formatter = logging.Formatter('%(asctime)s - %(levelname)s - %(message)s')
17 console_handler.setFormatter(formatter)
18 logging.getLogger('').addHandler(console_handler)
19 logging.info('logging start...')
20
21
22# 示例:记录一条信息

Callers 1

before_initFunction · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected