补充提交
This commit is contained in:
26
common/contants.py
Normal file
26
common/contants.py
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
|
||||||
|
import yaml
|
||||||
|
from utils.logger import get_logger
|
||||||
|
|
||||||
|
logger = get_logger(__name__)
|
||||||
|
|
||||||
|
ALERT_PUSH_URL = ""
|
||||||
|
|
||||||
|
|
||||||
|
def init_config(config_path: str = "config.yaml"):
|
||||||
|
"""
|
||||||
|
从配置文件初始化全局配置
|
||||||
|
|
||||||
|
Args:
|
||||||
|
config_path: 配置文件路径,默认为 config.yaml
|
||||||
|
"""
|
||||||
|
global ALERT_PUSH_URL
|
||||||
|
|
||||||
|
try:
|
||||||
|
with open(config_path, "r", encoding="utf-8") as f:
|
||||||
|
cfg = yaml.safe_load(f)
|
||||||
|
|
||||||
|
ALERT_PUSH_URL = cfg.get("alert_push_url", "")
|
||||||
|
logger.info(f"[INFO] Config initialized from {config_path}, alert_push_url={ALERT_PUSH_URL}")
|
||||||
|
|
||||||
|
except Exception as e:
|
||||||
Reference in New Issue
Block a user