Merge pull request #152 from lixinyu1011/workstation_dev_YB3

修改减少modbus报警信息,以及websocket报警信息
This commit is contained in:
Calvin Cao
2025-11-08 15:21:33 +08:00
committed by GitHub
2 changed files with 10 additions and 3 deletions

View File

@@ -421,7 +421,8 @@ class MessageProcessor:
ssl_context = ssl_module.create_default_context()
ws_logger = logging.getLogger("websockets.client")
ws_logger.setLevel(logging.INFO)
# ws_logger.setLevel(logging.INFO)
ws_logger.setLevel(logging.WARNING) # 只显示警告和错误
async with websockets.connect(
self.websocket_url,

View File

@@ -191,8 +191,14 @@ def configure_logger(loglevel=None):
# 添加处理器到根日志记录器
root_logger.addHandler(console_handler)
logging.getLogger("asyncio").setLevel(logging.INFO)
logging.getLogger("urllib3").setLevel(logging.INFO)
# 降低第三方库的日志级别,避免过多输出
# pymodbus 库的日志太详细,设置为 WARNING
logging.getLogger('pymodbus').setLevel(TRACE_LEVEL)
logging.getLogger('pymodbus.logging').setLevel(TRACE_LEVEL)
logging.getLogger('pymodbus.logging.base').setLevel(TRACE_LEVEL)
logging.getLogger('pymodbus.logging.decoders').setLevel(TRACE_LEVEL)
# 配置日志系统
configure_logger()