feat: 优化日志配置函数中的代码格式,提升可读性

This commit is contained in:
Your Name committed 2026-01-07 19:10:07 +08:00
1 parent 210014d5b1
commit 0e2ff7be6e
2 files changed
+11 -14

No files matched your search

+5 -13
View File
@@ -719,7 +719,8 @@ def configure_logging(
try:
# 计算当前日志总大小(MB)
pattern = os.path.join(
log_dir or path_config.get_logs_dir(), f"{os.path.basename(base_filename_base)}_*.log*"
log_dir or path_config.get_logs_dir(),
f"{os.path.basename(base_filename_base)}_*.log*",
)
total_size = 0
for p in glob.glob(pattern):
@@ -741,7 +742,9 @@ def configure_logging(
keep_days=keep_days,
max_total_size_gb=max_total_size_gb,
compress_after_days=compress_after_days,
compress=compress_logs if compress_logs is not None else True,
compress=(
compress_logs if compress_logs is not None else True
),
)
except Exception:
pass
@@ -749,22 +752,11 @@ def configure_logging(
# 启动日志监控器
if enable_monitor:
try:
# 从配置中读取是否允许运行时清理(默认为 False)
try:
enable_runtime_cleanup_cfg = False
if isinstance(log_config, dict):
enable_runtime_cleanup_cfg = bool(
log_config.get("enable_runtime_cleanup", False)
)
except Exception:
enable_runtime_cleanup_cfg = False
start_log_monitor(
logs_dir=log_dir or path_config.get_logs_dir(),
base_name=os.path.basename(base_filename_base),
warning_size_mb=monitor_warning_mb,
critical_size_mb=monitor_critical_mb,
enable_runtime_cleanup=enable_runtime_cleanup_cfg,
)
except Exception as e:
try:
+6 -1
View File
@@ -798,7 +798,12 @@
<div class="logHeader">
<div class="logTitle">运行日志</div>
<div class="logHeaderActions">
<input id="runLogSearch" class="logSearchBox" placeholder="搜索运行日志(回车或实时过滤)" />
<select id="runLogMode" class="small">
<option value="filter">筛选</option>
<option value="search">搜索</option>
</select>
<input id="runLogSearch" class="logSearchBox" placeholder="筛选/搜索运行日志" />
<button id="btnRunLogSearch" class="btn small">搜索</button>
<button id="btnRunLogClear" class="btn small">清除</button>
</div>
</div>