新增: 断点续跑与日志租约底座
This commit is contained in:
+7
-34
@@ -8,6 +8,9 @@ mod mcp;
|
||||
mod local_proxy_gateway;
|
||||
mod tray;
|
||||
mod feishu_channel;
|
||||
// 双进程共用日志初始化(数据目录落点+启动期轮转+%TEMP% 旧日志迁移)
|
||||
// main.rs 经 devflow_lib::logging 访问,须 pub
|
||||
pub mod logging;
|
||||
|
||||
use tauri::{Emitter, Listener, Manager};
|
||||
// UX-P2 走查⑥:首次关窗托盘化提示走 OS 系统通知(应用内气泡窗口即隐看不见),需 NotificationExt
|
||||
@@ -15,19 +18,6 @@ use tauri_plugin_notification::NotificationExt;
|
||||
|
||||
use state::AppState;
|
||||
|
||||
/// 用户本地时区日志时间戳格式化器。
|
||||
/// tracing_subscriber 默认输出 UTC,用户在中国 UTC+8,日志与本地时间差 8 小时不便调试。
|
||||
/// 使用 chrono::Local 输出含时区偏移的本地时间(如 "2026-07-17T15:30:00.123456+08:00")。
|
||||
///
|
||||
/// 注意:FormatTime::format_time 参数类型为 tracing_subscriber::fmt::format::Writer,
|
||||
/// 非 std::fmt::Write。Writer 实现了 fmt::Write,可直接 write!。
|
||||
struct LocalTimer;
|
||||
impl tracing_subscriber::fmt::time::FormatTime for LocalTimer {
|
||||
fn format_time(&self, w: &mut tracing_subscriber::fmt::format::Writer<'_>) -> std::fmt::Result {
|
||||
write!(w, "{}", chrono::Local::now().format("%Y-%m-%dT%H:%M:%S%.6f%:z"))
|
||||
}
|
||||
}
|
||||
|
||||
// Phase3 跨端隧道:TunnelClient trait(connect/send_raw_event/disconnect 方法)需在作用域内
|
||||
use df_tunnel::TunnelClient;
|
||||
|
||||
@@ -41,27 +31,10 @@ const TRAY_NOTICE_SENT_MARKER: &str = "tray-hide-notice-sent";
|
||||
|
||||
#[cfg_attr(mobile, tauri::mobile_entry_point)]
|
||||
pub fn run() {
|
||||
// 初始化文件日志:追加到 %TEMP%/devflow-trace.log,RUST_LOG 控制级别(默认 info)
|
||||
let log_path = std::env::temp_dir().join("devflow-trace.log");
|
||||
let log_file = std::fs::OpenOptions::new()
|
||||
.create(true)
|
||||
.append(true)
|
||||
.open(&log_path)
|
||||
.expect("创建日志文件失败");
|
||||
let (non_blocking, _guard) = tracing_appender::non_blocking(log_file);
|
||||
tracing_subscriber::fmt()
|
||||
.with_timer(LocalTimer)
|
||||
.with_env_filter(
|
||||
tracing_subscriber::EnvFilter::try_from_default_env()
|
||||
.unwrap_or_else(|_| tracing_subscriber::EnvFilter::new("info"))
|
||||
)
|
||||
.with_writer(non_blocking)
|
||||
.with_ansi(false)
|
||||
.init();
|
||||
tracing::info!(
|
||||
path = %log_path.display(),
|
||||
"[startup] 日志已初始化"
|
||||
);
|
||||
// 双进程共用日志初始化(logging.rs):落点系统应用数据目录 + 启动期 5MB 轮转 +
|
||||
// %TEMP% 旧日志迁移。治「使用数据分析-2026-10-04」登记项(%TEMP% 系统清理无声删除+无轮转)。
|
||||
// identifier 与 tauri.conf.json 一致(main.rs MCP 侧走编译期注入同源)。
|
||||
let _guard = logging::init_logging("top.1216.devflow", "gui");
|
||||
|
||||
tauri::Builder::default()
|
||||
.plugin(tauri_plugin_opener::init())
|
||||
|
||||
Reference in New Issue
Block a user