Skip to content

Commit 630a7f4

Browse files
authored
refactor: remove mobile log initialization, ref #6049 (#6081)
1 parent 276a036 commit 630a7f4

12 files changed

Lines changed: 22 additions & 83 deletions

File tree

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
"tauri-utils": patch
3+
"tauri-codegen": patch
4+
---
5+
6+
Added `crate_name` field on `PackageInfo`.

.changes/remove-mobile-log.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
---
2+
"tauri": patch
3+
"tauri-macros": patch
4+
"tauri-build": patch
5+
---
6+
7+
Removed mobile logging initialization, which will be handled by `tauri-plugin-log`.

core/tauri-build/src/lib.rs

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -221,20 +221,14 @@ pub fn try_build(attributes: Attributes) -> Result<()> {
221221

222222
let s = config.tauri.bundle.identifier.split('.');
223223
let last = s.clone().count() - 1;
224-
let mut domain = String::new();
225224
let mut android_package_prefix = String::new();
226225
for (i, w) in s.enumerate() {
227226
if i != last {
228-
domain.push_str(w);
229-
domain.push('.');
230-
231227
android_package_prefix.push_str(w);
232228
android_package_prefix.push('_');
233229
}
234230
}
235-
domain.pop();
236231
android_package_prefix.pop();
237-
println!("cargo:rustc-env=TAURI_MOBILE_DOMAIN={domain}");
238232
println!("cargo:rustc-env=TAURI_ANDROID_PACKAGE_PREFIX={android_package_prefix}");
239233

240234
cfg_alias("dev", !has_feature("custom-protocol"));

core/tauri-codegen/src/context.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -303,6 +303,7 @@ pub fn context_codegen(data: ContextData) -> Result<TokenStream, EmbeddedAssetsE
303303
version: #package_version.parse().unwrap(),
304304
authors: env!("CARGO_PKG_AUTHORS"),
305305
description: env!("CARGO_PKG_DESCRIPTION"),
306+
crate_name: env!("CARGO_PKG_NAME"),
306307
}
307308
);
308309

core/tauri-macros/src/mobile.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,6 @@ pub fn entry_point(_attributes: TokenStream, item: TokenStream) -> TokenStream {
4040
&mut error,
4141
&function,
4242
);
43-
let domain_str = var("TAURI_MOBILE_DOMAIN").unwrap();
44-
let app_name_str = var("CARGO_PKG_NAME").unwrap();
4543

4644
if let Some(e) = error {
4745
quote!(#e).into()
@@ -61,10 +59,9 @@ pub fn entry_point(_attributes: TokenStream, item: TokenStream) -> TokenStream {
6159

6260
fn _start_app() {
6361
#[cfg(target_os = "ios")]
64-
::tauri::init_logging(&format!("{}.{}", #domain_str, #app_name_str));
62+
::tauri::log_stdout();
6563
#[cfg(target_os = "android")]
6664
{
67-
::tauri::init_logging(#app_name_str);
6865
use ::tauri::paste;
6966
::tauri::wry_android_binding!(#domain, #app_name, _start_app, ::tauri::wry);
7067
}

core/tauri-utils/src/lib.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,8 @@ pub struct PackageInfo {
3434
pub authors: &'static str,
3535
/// The crate description.
3636
pub description: &'static str,
37+
/// The crate name.
38+
pub crate_name: &'static str,
3739
}
3840

3941
impl PackageInfo {

core/tauri/Cargo.toml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -110,11 +110,9 @@ win7-notifications = { version = "0.3.1", optional = true }
110110

111111
[target."cfg(target_os = \"android\")".dependencies]
112112
paste = "1.0"
113-
android_logger = "0.9"
114113
log = "0.4"
115114

116115
[target."cfg(target_os = \"ios\")".dependencies]
117-
oslog = "0.2"
118116
log = "0.4"
119117
libc = "0.2"
120118

core/tauri/src/lib.rs

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -278,19 +278,9 @@ pub use self::runtime::ClipboardManager;
278278
#[cfg_attr(doc_cfg, doc(cfg(feature = "global-shortcut")))]
279279
pub use self::runtime::GlobalShortcutManager;
280280

281-
#[cfg(target_os = "android")]
282-
#[doc(hidden)]
283-
pub fn init_logging(tag: &str) {
284-
android_logger::init_once(
285-
android_logger::Config::default()
286-
.with_min_level(log::Level::Trace)
287-
.with_tag(tag),
288-
);
289-
}
290-
291281
#[cfg(target_os = "ios")]
292282
#[doc(hidden)]
293-
pub fn init_logging(subsystem: &str) {
283+
pub fn log_stdout() {
294284
use std::{
295285
ffi::CString,
296286
fs::File,
@@ -323,11 +313,6 @@ pub fn init_logging(subsystem: &str) {
323313
}
324314
}
325315
});
326-
327-
oslog::OsLogger::new(subsystem)
328-
.level_filter(log::LevelFilter::Trace)
329-
.init()
330-
.unwrap();
331316
}
332317

333318
/// Updater events.

core/tauri/src/test/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ pub fn mock_context<A: Assets>(assets: A) -> crate::Context<A> {
7474
version: "0.1.0".parse().unwrap(),
7575
authors: "Tauri",
7676
description: "Tauri test",
77+
crate_name: "test",
7778
},
7879
_info_plist: (),
7980
pattern: Pattern::Brownfield(std::marker::PhantomData),

examples/api/src-tauri/Cargo.lock

Lines changed: 1 addition & 54 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)