refactor: remove mobile log initialization, ref #6049 (#6081)

This commit is contained in:
Lucas Fernandes Nogueira 2023-01-17 08:13:53 -08:00 committed by GitHub
parent 276a0362de
commit 630a7f4b18
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
12 changed files with 22 additions and 83 deletions

View File

@ -0,0 +1,6 @@
---
"tauri-utils": patch
"tauri-codegen": patch
---
Added `crate_name` field on `PackageInfo`.

View File

@ -0,0 +1,7 @@
---
"tauri": patch
"tauri-macros": patch
"tauri-build": patch
---
Removed mobile logging initialization, which will be handled by `tauri-plugin-log`.

View File

@ -221,20 +221,14 @@ pub fn try_build(attributes: Attributes) -> Result<()> {
let s = config.tauri.bundle.identifier.split('.'); let s = config.tauri.bundle.identifier.split('.');
let last = s.clone().count() - 1; let last = s.clone().count() - 1;
let mut domain = String::new();
let mut android_package_prefix = String::new(); let mut android_package_prefix = String::new();
for (i, w) in s.enumerate() { for (i, w) in s.enumerate() {
if i != last { if i != last {
domain.push_str(w);
domain.push('.');
android_package_prefix.push_str(w); android_package_prefix.push_str(w);
android_package_prefix.push('_'); android_package_prefix.push('_');
} }
} }
domain.pop();
android_package_prefix.pop(); android_package_prefix.pop();
println!("cargo:rustc-env=TAURI_MOBILE_DOMAIN={domain}");
println!("cargo:rustc-env=TAURI_ANDROID_PACKAGE_PREFIX={android_package_prefix}"); println!("cargo:rustc-env=TAURI_ANDROID_PACKAGE_PREFIX={android_package_prefix}");
cfg_alias("dev", !has_feature("custom-protocol")); cfg_alias("dev", !has_feature("custom-protocol"));

View File

@ -303,6 +303,7 @@ pub fn context_codegen(data: ContextData) -> Result<TokenStream, EmbeddedAssetsE
version: #package_version.parse().unwrap(), version: #package_version.parse().unwrap(),
authors: env!("CARGO_PKG_AUTHORS"), authors: env!("CARGO_PKG_AUTHORS"),
description: env!("CARGO_PKG_DESCRIPTION"), description: env!("CARGO_PKG_DESCRIPTION"),
crate_name: env!("CARGO_PKG_NAME"),
} }
); );

View File

@ -40,8 +40,6 @@ pub fn entry_point(_attributes: TokenStream, item: TokenStream) -> TokenStream {
&mut error, &mut error,
&function, &function,
); );
let domain_str = var("TAURI_MOBILE_DOMAIN").unwrap();
let app_name_str = var("CARGO_PKG_NAME").unwrap();
if let Some(e) = error { if let Some(e) = error {
quote!(#e).into() quote!(#e).into()
@ -61,10 +59,9 @@ pub fn entry_point(_attributes: TokenStream, item: TokenStream) -> TokenStream {
fn _start_app() { fn _start_app() {
#[cfg(target_os = "ios")] #[cfg(target_os = "ios")]
::tauri::init_logging(&format!("{}.{}", #domain_str, #app_name_str)); ::tauri::log_stdout();
#[cfg(target_os = "android")] #[cfg(target_os = "android")]
{ {
::tauri::init_logging(#app_name_str);
use ::tauri::paste; use ::tauri::paste;
::tauri::wry_android_binding!(#domain, #app_name, _start_app, ::tauri::wry); ::tauri::wry_android_binding!(#domain, #app_name, _start_app, ::tauri::wry);
} }

View File

@ -34,6 +34,8 @@ pub struct PackageInfo {
pub authors: &'static str, pub authors: &'static str,
/// The crate description. /// The crate description.
pub description: &'static str, pub description: &'static str,
/// The crate name.
pub crate_name: &'static str,
} }
impl PackageInfo { impl PackageInfo {

View File

@ -110,11 +110,9 @@ win7-notifications = { version = "0.3.1", optional = true }
[target."cfg(target_os = \"android\")".dependencies] [target."cfg(target_os = \"android\")".dependencies]
paste = "1.0" paste = "1.0"
android_logger = "0.9"
log = "0.4" log = "0.4"
[target."cfg(target_os = \"ios\")".dependencies] [target."cfg(target_os = \"ios\")".dependencies]
oslog = "0.2"
log = "0.4" log = "0.4"
libc = "0.2" libc = "0.2"

View File

@ -278,19 +278,9 @@ pub use self::runtime::ClipboardManager;
#[cfg_attr(doc_cfg, doc(cfg(feature = "global-shortcut")))] #[cfg_attr(doc_cfg, doc(cfg(feature = "global-shortcut")))]
pub use self::runtime::GlobalShortcutManager; pub use self::runtime::GlobalShortcutManager;
#[cfg(target_os = "android")]
#[doc(hidden)]
pub fn init_logging(tag: &str) {
android_logger::init_once(
android_logger::Config::default()
.with_min_level(log::Level::Trace)
.with_tag(tag),
);
}
#[cfg(target_os = "ios")] #[cfg(target_os = "ios")]
#[doc(hidden)] #[doc(hidden)]
pub fn init_logging(subsystem: &str) { pub fn log_stdout() {
use std::{ use std::{
ffi::CString, ffi::CString,
fs::File, fs::File,
@ -323,11 +313,6 @@ pub fn init_logging(subsystem: &str) {
} }
} }
}); });
oslog::OsLogger::new(subsystem)
.level_filter(log::LevelFilter::Trace)
.init()
.unwrap();
} }
/// Updater events. /// Updater events.

View File

@ -74,6 +74,7 @@ pub fn mock_context<A: Assets>(assets: A) -> crate::Context<A> {
version: "0.1.0".parse().unwrap(), version: "0.1.0".parse().unwrap(),
authors: "Tauri", authors: "Tauri",
description: "Tauri test", description: "Tauri test",
crate_name: "test",
}, },
_info_plist: (), _info_plist: (),
pattern: Pattern::Brownfield(std::marker::PhantomData), pattern: Pattern::Brownfield(std::marker::PhantomData),

View File

@ -67,24 +67,6 @@ dependencies = [
"alloc-no-stdlib", "alloc-no-stdlib",
] ]
[[package]]
name = "android_log-sys"
version = "0.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "85965b6739a430150bdd138e2374a98af0c3ee0d030b3bb7fc3bddff58d0102e"
[[package]]
name = "android_logger"
version = "0.9.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2ec2333c185d826313162cee39d3fcc6a84ba08114a839bebf53b961e7e75773"
dependencies = [
"android_log-sys",
"env_logger",
"lazy_static",
"log",
]
[[package]] [[package]]
name = "anyhow" name = "anyhow"
version = "1.0.66" version = "1.0.66"
@ -95,6 +77,7 @@ checksum = "216261ddc8289130e551ddcd5ce8a064710c0d064a4d2895c67151c92b5443f6"
name = "api" name = "api"
version = "0.1.0" version = "0.1.0"
dependencies = [ dependencies = [
"log",
"serde", "serde",
"serde_json", "serde_json",
"tauri", "tauri",
@ -610,19 +593,6 @@ dependencies = [
"syn", "syn",
] ]
[[package]]
name = "dashmap"
version = "5.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "907076dfda823b0b36d2a1bb5f90c96660a5bbcd7729e10727f07858f22c4edc"
dependencies = [
"cfg-if",
"hashbrown",
"lock_api",
"once_cell",
"parking_lot_core",
]
[[package]] [[package]]
name = "dbus" name = "dbus"
version = "0.9.6" version = "0.9.6"
@ -720,16 +690,6 @@ dependencies = [
"cfg-if", "cfg-if",
] ]
[[package]]
name = "env_logger"
version = "0.7.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "44533bbbb3bb3c1fa17d9f2e4e38bbbaf8396ba82193c4cb1b6445d711445d36"
dependencies = [
"log",
"regex",
]
[[package]] [[package]]
name = "fastrand" name = "fastrand"
version = "1.8.0" version = "1.8.0"
@ -1935,17 +1895,6 @@ version = "6.3.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3baf96e39c5359d2eb0dd6ccb42c62b91d9678aa68160d261b9e0ccbf9e9dea9" checksum = "3baf96e39c5359d2eb0dd6ccb42c62b91d9678aa68160d261b9e0ccbf9e9dea9"
[[package]]
name = "oslog"
version = "0.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "80d2043d1f61d77cb2f4b1f7b7b2295f40507f5f8e9d1c8bf10a1ca5f97a3969"
dependencies = [
"cc",
"dashmap",
"log",
]
[[package]] [[package]]
name = "overload" name = "overload"
version = "0.1.1" version = "0.1.1"
@ -2953,7 +2902,6 @@ dependencies = [
name = "tauri" name = "tauri"
version = "2.0.0-alpha.2" version = "2.0.0-alpha.2"
dependencies = [ dependencies = [
"android_logger",
"anyhow", "anyhow",
"attohttpc", "attohttpc",
"base64", "base64",
@ -2982,7 +2930,6 @@ dependencies = [
"open", "open",
"os_info", "os_info",
"os_pipe", "os_pipe",
"oslog",
"paste", "paste",
"percent-encoding", "percent-encoding",
"png", "png",

View File

@ -16,6 +16,7 @@ tauri-build = { path = "../../../core/tauri-build", features = ["codegen", "isol
serde_json = "1.0" serde_json = "1.0"
serde = { version = "1.0", features = [ "derive" ] } serde = { version = "1.0", features = [ "derive" ] }
tiny_http = "0.11" tiny_http = "0.11"
log = "0.4"
[dependencies.tauri] [dependencies.tauri]
path = "../../../core/tauri" path = "../../../core/tauri"

View File

@ -14,7 +14,7 @@ pub struct RequestBody {
#[command] #[command]
pub fn log_operation(event: String, payload: Option<String>) { pub fn log_operation(event: String, payload: Option<String>) {
println!("{} {:?}", event, payload); log::info!("{} {:?}", event, payload);
} }
#[command] #[command]