[tauri-plugin-log] How to Obtain app_handle to Emit Events in Custom Log Targets? #13509
-
pub fn run() {
let __builder = tauri::Builder::default()
.plugin(
tauri_plugin_log::Builder::new()
.clear_targets()
.target(tauri_plugin_log::Target::new(
tauri_plugin_log::TargetKind::Dispatch(
fern::Dispatch::new()
.chain(fern::Output::call(|record| {
println!("{}", record.args());
// emit
// app.emit("mylog://log", "msg ..");
})),
),
))
.build(),
)
.setup(|app| {
Ok(())
})
.invoke_handler(tauri::generate_handler![])
.run(tauri::generate_context!())
.expect("error while running tauri application");
} |
Beta Was this translation helpful? Give feedback.
Answered by
FabianLars
May 26, 2025
Replies: 1 comment
-
You can register the plugin inside the setup hook as well instead of on the Builder. There you'll have easy access to an AppHandle. That registers the logger a tiny bit later though so some plugin's logs mayyy get missed? |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
mcitem
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
You can register the plugin inside the setup hook as well instead of on the Builder. There you'll have easy access to an AppHandle. That registers the logger a tiny bit later though so some plugin's logs mayyy get missed?