Skip to content

Commit 6c5340f

Browse files
authored
feat(cli): add log plugin to the app template (#11004)
* feat(cli): add log plugin to the app template The log plugin is really important for mobile development - without it you don't have a clue about logs and stdout for iOS apps * patch tauri dep for local testing * clippy
1 parent 35bd9dd commit 6c5340f

File tree

5 files changed

+29
-4
lines changed

5 files changed

+29
-4
lines changed
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
"@tauri-apps/cli": patch:enhance
3+
"tauri-cli": patch:enhance
4+
---
5+
6+
Added the `log` plugin to the app template, which is required to visualize logs on Android and iOS.

crates/tauri-cli/src/init.rs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -196,15 +196,15 @@ pub fn command(mut options: Options) -> Result<()> {
196196
template_target_path
197197
);
198198
} else {
199-
let (tauri_dep, tauri_build_dep) = if let Some(tauri_path) = options.tauri_path {
199+
let (tauri_dep, tauri_build_dep) = if let Some(tauri_path) = &options.tauri_path {
200200
(
201201
format!(
202202
r#"{{ path = {:?} }}"#,
203-
resolve_tauri_path(&tauri_path, "crates/tauri")
203+
resolve_tauri_path(tauri_path, "crates/tauri")
204204
),
205205
format!(
206206
"{{ path = {:?} }}",
207-
resolve_tauri_path(&tauri_path, "crates/tauri-build")
207+
resolve_tauri_path(tauri_path, "crates/tauri-build")
208208
),
209209
)
210210
} else {
@@ -220,6 +220,9 @@ pub fn command(mut options: Options) -> Result<()> {
220220

221221
let mut data = BTreeMap::new();
222222
data.insert("tauri_dep", to_json(tauri_dep));
223+
if options.tauri_path.is_some() {
224+
data.insert("patch_tauri_dep", to_json(true));
225+
}
223226
data.insert("tauri_build_dep", to_json(tauri_build_dep));
224227
data.insert(
225228
"frontend_dist",

crates/tauri-cli/templates/app/src-tauri/Cargo.crate-manifest

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,4 +20,10 @@ tauri-build = {{ tauri_build_dep }}
2020
[dependencies]
2121
serde_json = "1.0"
2222
serde = { version = "1.0", features = ["derive"] }
23+
log = "0.4"
2324
tauri = {{ tauri_dep }}
25+
tauri-plugin-log = "2.0.0-rc"
26+
{{#if patch_tauri_dep}}
27+
[patch.crates-io]
28+
tauri = {{ tauri_dep }}
29+
{{/if}}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,16 @@
11
#[cfg_attr(mobile, tauri::mobile_entry_point)]
22
pub fn run() {
33
tauri::Builder::default()
4+
.setup(|app| {
5+
if cfg!(debug_assertions) {
6+
app.handle().plugin(
7+
tauri_plugin_log::Builder::default()
8+
.level(log::LevelFilter::Info)
9+
.build(),
10+
)?;
11+
}
12+
Ok(())
13+
})
414
.run(tauri::generate_context!())
515
.expect("error while running tauri application");
616
}

crates/tauri/src/process.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ pub fn restart(env: &Env) -> ! {
9292
}
9393

9494
#[cfg(target_os = "macos")]
95-
fn restart_macos_app(current_binary: &PathBuf, env: &Env) {
95+
fn restart_macos_app(current_binary: &std::path::Path, env: &Env) {
9696
use std::process::{exit, Command};
9797

9898
if let Some(macos_directory) = current_binary.parent() {

0 commit comments

Comments
 (0)