Files
pangolin/client/lib/bridge/log.dart
T
wangjia b9e5dbec9b
ci-pangolin / Lint — shellcheck (push) Has been cancelled
ci-pangolin / OpenAPI Sync Check (push) Has been cancelled
ci-pangolin / Redline Scan — 脱敏 (UI 文案) (push) Has been cancelled
ci-pangolin / Flutter — analyze + test (push) Has been cancelled
refactor(client): 抽统一日志函数 logLine + 去掉重复时间戳
- log_time.dart → log.dart:提供 logLine(tag, msg),格式 `[时:分:秒.毫秒] [tag] msg`,
  DesktopKernel / DesktopVpnBridge 散落的 print+拼接全部收敛到此。
- 下发配置 log.timestamp=false:sing-box 不再自带时间戳,避免一行打印两个时间
  (之前 `[22:10:35.213] [stderr] +0800 2026-06-18 22:10:35 ...` 重复)。

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-18 22:17:09 +08:00

16 lines
627 B
Dart

// log.dart — 桌面端统一日志出口。
// 格式: `[时:分:秒.毫秒] [tag] msg`,全部走 logLine(),便于排查时序。
// 注:sing-box 自身时间戳已在下发配置里关闭(log.timestamp=false),
// 避免与这里的前缀重复打印两个时间。
// ignore_for_file: avoid_print
String _ts() {
final n = DateTime.now();
String p(int v, [int w = 2]) => v.toString().padLeft(w, '0');
return '${p(n.hour)}:${p(n.minute)}:${p(n.second)}.${p(n.millisecond, 3)}';
}
/// 打印一行带时间戳与标签的桌面端日志。
void logLine(String tag, String msg) => print('[${_ts()}] [$tag] $msg');