diff --git a/clash_lib/Cargo.toml b/clash_lib/Cargo.toml index 12043dde4..844d7ba1e 100644 --- a/clash_lib/Cargo.toml +++ b/clash_lib/Cargo.toml @@ -109,7 +109,6 @@ ring-compat = { version = "0.8", features = ["aead"] } rand = "0.8" tracing = "0.1" tracing-subscriber = { version = "0.3", features = ["env-filter"] } -tracing-oslog = { branch = "main", git = "https://github.com/Absolucy/tracing-oslog.git" } tracing-appender = "0.2" shadowsocks = { version="1.21", optional = true, features=["aead-cipher-2022","stream-cipher"] } @@ -157,6 +156,9 @@ unix-udp-sock = { git = "https://github.com/Watfaq/unix-udp-sock.git", rev = "cd [target.'cfg(macos)'.dependencies] security-framework = "3.0.1" +[target.'cfg(target_os="ios")'.dependencies] +tracing-oslog = { branch = "main", git = "https://github.com/Absolucy/tracing-oslog.git" } + [target.'cfg(windows)'.dependencies] windows = { version = "0.58", features = [ "Win32_Networking_WinSock", diff --git a/clash_lib/src/app/logging.rs b/clash_lib/src/app/logging.rs index e9ad51f3d..fbf3572da 100644 --- a/clash_lib/src/app/logging.rs +++ b/clash_lib/src/app/logging.rs @@ -20,6 +20,7 @@ use tokio::sync::broadcast::Sender; use tracing::debug; use tracing_appender::non_blocking::WorkerGuard; +#[cfg(target_os = "ios")] use tracing_oslog::OsLogger; use tracing_subscriber::{ filter::{self, filter_fn, Directive}, @@ -125,11 +126,11 @@ pub fn setup_logging( None }; - let ios_os_log = if cfg!(target_os = "ios") { - Some(OsLogger::new("com.watfaq.clash", "default")) - } else { - None - }; + #[cfg(target_os = "ios")] + let ios_os_log = Some(OsLogger::new("com.watfaq.clash", "default")); + #[cfg(not(target_os = "ios"))] + let ios_os_log = + tracing_subscriber::fmt::Layer::new().with_writer(std::io::empty); let (appender, g) = if let Some(log_file) = log_file { let file_appender = tracing_appender::rolling::daily(cwd, log_file);