Skip to content

Commit 832be2d

Browse files
committed
Revert "debug: add early startup probe logging"
This reverts commit 1915563.
1 parent 1915563 commit 832be2d

5 files changed

Lines changed: 22 additions & 293 deletions

File tree

src-tauri/src/app/mod.rs

Lines changed: 11 additions & 98 deletions
Original file line numberDiff line numberDiff line change
@@ -15,133 +15,46 @@ use crate::commands;
1515
use components::tray;
1616

1717
pub fn run() {
18-
crate::core::logger::startup_probe::log("app::run: entered");
1918
let ctx = tauri::generate_context!();
20-
crate::core::logger::startup_probe::log("app::run: tauri context generated");
2119
let session_lock_manager = session_lock::SessionLockManager::new();
22-
crate::core::logger::startup_probe::log("app::run: session lock manager created");
2320

24-
let builder = tauri::Builder::default()
21+
let app = tauri::Builder::default()
2522
.manage(session_lock_manager.clone())
2623
.setup(move |app| {
27-
crate::core::logger::startup_probe::log("app::run setup: begin");
28-
setup::register_plugins(app.handle()).map_err(|error| {
29-
crate::core::logger::startup_probe::log_error(
30-
"app::run setup: register_plugins failed",
31-
error.to_string(),
32-
);
33-
anyhow::anyhow!("{}", error)
34-
})?;
35-
crate::core::logger::startup_probe::log("app::run setup: after register_plugins");
24+
setup::register_plugins(app.handle());
3625

3726
crate::infrastructure::persistence::tauri_store::ensure_store_loaded(app.handle())
38-
.map_err(|e| {
39-
crate::core::logger::startup_probe::log_error(
40-
"app::run setup: ensure_store_loaded failed",
41-
e.to_string(),
42-
);
43-
anyhow::anyhow!("{}", e)
44-
})?;
45-
crate::core::logger::startup_probe::log("app::run setup: after ensure_store_loaded");
27+
.map_err(|e| anyhow::anyhow!("{}", e))?;
4628
let log_dir =
4729
crate::infrastructure::persistence::tauri_store::get_logs_path(app.handle())
48-
.map_err(|e| {
49-
crate::core::logger::startup_probe::log_error(
50-
"app::run setup: get_logs_path failed",
51-
e.to_string(),
52-
);
53-
anyhow::anyhow!("{}", e)
54-
})?;
55-
crate::core::logger::startup_probe::log(format!(
56-
"app::run setup: resolved logs path={}",
57-
log_dir.display()
58-
));
30+
.map_err(|e| anyhow::anyhow!("{}", e))?;
5931
crate::core::logger::init_logging(&log_dir);
60-
crate::core::logger::startup_probe::log("app::run setup: after logger re-init");
61-
setup::register_deep_link(app.handle().clone()).map_err(|error| {
62-
crate::core::logger::startup_probe::log_error(
63-
"app::run setup: register_deep_link failed",
64-
error.to_string(),
65-
);
66-
error
67-
})?;
68-
crate::core::logger::startup_probe::log("app::run setup: after register_deep_link");
32+
setup::register_deep_link(app.handle().clone())?;
6933

70-
crate::commands::window::create_splashscreen_window(app.handle().clone()).map_err(
71-
|error| {
72-
crate::core::logger::startup_probe::log_error(
73-
"app::run setup: create_splashscreen_window failed",
74-
error.to_string(),
75-
);
76-
error
77-
},
78-
)?;
79-
crate::core::logger::startup_probe::log(
80-
"app::run setup: after create_splashscreen_window",
81-
);
34+
crate::commands::window::create_splashscreen_window(app.handle().clone())?;
8235

83-
tray::menu(app).map_err(|error| {
84-
crate::core::logger::startup_probe::log_error(
85-
"app::run setup: tray::menu failed",
86-
error.to_string(),
87-
);
88-
error
89-
})?;
90-
crate::core::logger::startup_probe::log("app::run setup: after tray::menu");
36+
tray::menu(app)?;
9137

9238
// 初始化依赖 Tauri 的组件
93-
lifecycle::init_tauri_dependent(app.handle()).map_err(|error| {
94-
crate::core::logger::startup_probe::log_error(
95-
"app::run setup: init_tauri_dependent failed",
96-
error.to_string(),
97-
);
98-
error
99-
})?;
100-
crate::core::logger::startup_probe::log(
101-
"app::run setup: after lifecycle::init_tauri_dependent",
102-
);
39+
lifecycle::init_tauri_dependent(app.handle())?;
10340

10441
setup::init_simprint_runtime_background(app.handle().clone());
105-
crate::core::logger::startup_probe::log(
106-
"app::run setup: after init_simprint_runtime_background",
107-
);
10842

10943
// 初始化会话自动锁定后台任务
11044
session_lock::init_session_lock_background(
11145
app.handle().clone(),
11246
session_lock_manager.clone(),
11347
);
114-
crate::core::logger::startup_probe::log(
115-
"app::run setup: after init_session_lock_background",
116-
);
11748

11849
// 初始化应用启动流程(显示 splashscreen)
11950
splashscreen::init_startup(app.handle().clone());
120-
crate::core::logger::startup_probe::log(
121-
"app::run setup: after splashscreen::init_startup",
122-
);
123-
crate::core::logger::startup_probe::log("app::run setup: completed");
12451

12552
Ok(())
12653
})
12754
.invoke_handler(commands::register_handles())
128-
.on_window_event(events::window_event_handle);
129-
130-
crate::core::logger::startup_probe::log("app::run: before builder.build(ctx)");
131-
let app = match builder.build(ctx) {
132-
Ok(app) => {
133-
crate::core::logger::startup_probe::log("app::run: after builder.build(ctx)");
134-
app
135-
}
136-
Err(error) => {
137-
crate::core::logger::startup_probe::log_error(
138-
"app::run: builder.build(ctx) failed",
139-
error.to_string(),
140-
);
141-
panic!("error while building application: {}", error);
142-
}
143-
};
55+
.on_window_event(events::window_event_handle)
56+
.build(ctx)
57+
.expect("error while building application");
14458

145-
crate::core::logger::startup_probe::log("app::run: before app.run");
14659
app.run(events::run_event_handle);
14760
}

src-tauri/src/app/setup.rs

Lines changed: 10 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,7 @@ use tauri::{AppHandle, Emitter};
33
use tauri_plugin_autostart::MacosLauncher;
44

55
/// 注册插件
6-
pub fn register_plugins(app_handle: &AppHandle) -> anyhow::Result<()> {
7-
crate::core::logger::startup_probe::log("setup::register_plugins: begin");
8-
6+
pub fn register_plugins(app_handle: &AppHandle) {
97
// Register the single instance plugin
108
#[cfg(any(target_os = "windows", target_os = "macos", target_os = "linux"))]
119
#[cfg(feature = "production")]
@@ -29,51 +27,27 @@ pub fn register_plugins(app_handle: &AppHandle) -> anyhow::Result<()> {
2927
let _ = main_window.set_focus();
3028
}
3129
}))
32-
.map_err(|error| anyhow::anyhow!("single_instance plugin init failed: {}", error))?;
33-
#[cfg(any(target_os = "windows", target_os = "macos", target_os = "linux"))]
34-
#[cfg(feature = "production")]
35-
crate::core::logger::startup_probe::log("setup::register_plugins: single_instance ok");
30+
.unwrap();
3631

3732
// Register process plugin
38-
app_handle
39-
.plugin(tauri_plugin_process::init())
40-
.map_err(|error| anyhow::anyhow!("process plugin init failed: {}", error))?;
41-
crate::core::logger::startup_probe::log("setup::register_plugins: process ok");
33+
app_handle.plugin(tauri_plugin_process::init()).unwrap();
4234

43-
app_handle
44-
.plugin(tauri_plugin_upload::init())
45-
.map_err(|error| anyhow::anyhow!("upload plugin init failed: {}", error))?;
46-
crate::core::logger::startup_probe::log("setup::register_plugins: upload ok");
35+
app_handle.plugin(tauri_plugin_upload::init()).unwrap();
4736

4837
// deep-link 插件
49-
app_handle
50-
.plugin(tauri_plugin_deep_link::init())
51-
.map_err(|error| anyhow::anyhow!("deep_link plugin init failed: {}", error))?;
52-
crate::core::logger::startup_probe::log("setup::register_plugins: deep_link ok");
38+
app_handle.plugin(tauri_plugin_deep_link::init()).unwrap();
5339

5440
// opener 插件
55-
app_handle
56-
.plugin(tauri_plugin_opener::init())
57-
.map_err(|error| anyhow::anyhow!("opener plugin init failed: {}", error))?;
58-
crate::core::logger::startup_probe::log("setup::register_plugins: opener ok");
41+
app_handle.plugin(tauri_plugin_opener::init()).unwrap();
5942

6043
// dialog 插件
61-
app_handle
62-
.plugin(tauri_plugin_dialog::init())
63-
.map_err(|error| anyhow::anyhow!("dialog plugin init failed: {}", error))?;
64-
crate::core::logger::startup_probe::log("setup::register_plugins: dialog ok");
44+
app_handle.plugin(tauri_plugin_dialog::init()).unwrap();
6545

6646
// store 插件
67-
app_handle
68-
.plugin(tauri_plugin_store::Builder::new().build())
69-
.map_err(|error| anyhow::anyhow!("store plugin init failed: {}", error))?;
70-
crate::core::logger::startup_probe::log("setup::register_plugins: store ok");
47+
app_handle.plugin(tauri_plugin_store::Builder::new().build()).unwrap();
7148

7249
// clipboard_manager
73-
app_handle
74-
.plugin(tauri_plugin_clipboard_manager::init())
75-
.map_err(|error| anyhow::anyhow!("clipboard_manager plugin init failed: {}", error))?;
76-
crate::core::logger::startup_probe::log("setup::register_plugins: clipboard_manager ok");
50+
app_handle.plugin(tauri_plugin_clipboard_manager::init()).unwrap();
7751

7852
// 自动启动插件
7953
#[cfg(desktop)]
@@ -82,24 +56,17 @@ pub fn register_plugins(app_handle: &AppHandle) -> anyhow::Result<()> {
8256
MacosLauncher::LaunchAgent,
8357
Some(vec![]), /* 传递给应用程序的任意数量的参数 */
8458
))
85-
.map_err(|error| anyhow::anyhow!("autostart plugin init failed: {}", error))?;
86-
#[cfg(desktop)]
87-
crate::core::logger::startup_probe::log("setup::register_plugins: autostart ok");
88-
89-
crate::core::logger::startup_probe::log("setup::register_plugins: completed");
90-
Ok(())
59+
.unwrap();
9160
}
9261

9362
/// 注册深度链接
9463
#[allow(dead_code)]
9564
pub fn register_deep_link(app: AppHandle) -> Result<(), anyhow::Error> {
96-
crate::core::logger::startup_probe::log("setup::register_deep_link: begin");
9765
#[cfg(any(windows, target_os = "linux"))]
9866
{
9967
use tauri_plugin_deep_link::DeepLinkExt;
10068
app.deep_link().register_all()?;
10169
};
102-
crate::core::logger::startup_probe::log("setup::register_deep_link: completed");
10370
Ok(())
10471
}
10572

@@ -122,26 +89,15 @@ pub fn init_server_public_key_background(app_handle: AppHandle) {
12289
}
12390

12491
pub fn init_simprint_runtime_background(app_handle: AppHandle) {
125-
crate::core::logger::startup_probe::log("setup::init_simprint_runtime_background: spawn");
12692
tauri::async_runtime::spawn(async move {
12793
use crate::app::context::AppContext;
12894

129-
crate::core::logger::startup_probe::log(
130-
"setup::init_simprint_runtime_background: task begin",
131-
);
13295
let ctx = AppContext::get();
13396
ctx.simprint_runtime_manager.set_app_handle(app_handle.clone()).await;
13497
ctx.runtime_update_service.start_background(app_handle.clone());
13598

13699
if let Err(error) = ctx.simprint_runtime_manager.start_background().await {
137-
crate::core::logger::startup_probe::log_error(
138-
"setup::init_simprint_runtime_background: start_background failed",
139-
error.to_string(),
140-
);
141100
log::warn!("failed to start simprint-runtime: {}", error);
142101
}
143-
crate::core::logger::startup_probe::log(
144-
"setup::init_simprint_runtime_background: task completed",
145-
);
146102
});
147103
}

src-tauri/src/core/logger/mod.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
1010
mod channels;
1111
pub mod modules;
12-
pub mod startup_probe;
1312
mod writer;
1413

1514
pub use channels::{Channel, file_stem_for_target, log_path_for_target};

src-tauri/src/core/logger/startup_probe.rs

Lines changed: 0 additions & 94 deletions
This file was deleted.

0 commit comments

Comments
 (0)