实现 RS485Manager

This commit is contained in:
2025-10-08 19:36:48 +08:00
parent fe1c307129
commit 46922e8505
9 changed files with 279 additions and 23 deletions

23
main/logs/logger.py Normal file
View File

@@ -0,0 +1,23 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
一个简单的、可配置的日志记录器模块。
"""
from main.config.config import *
def log(message: str):
"""
打印一条日志消息,是否实际输出取决于配置文件。
Args:
message (str): 要打印的日志消息。
"""
# 从配置文件中获取调试开关的状态
# .get()方法可以安全地获取值如果键不存在则返回默认值False
if SYSTEM_PARAMS.get('debug_enabled', False):
print(message)
# 如果开关为False此函数会立即返回不执行任何操作。