Files
pig-house-controller/main/logs/logger.py
2025-10-08 19:36:48 +08:00

24 lines
618 B
Python
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#!/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此函数会立即返回不执行任何操作。