diff options
| author | Joakim Hulthe <joakim.hulthe@mullvad.net> | 2025-02-21 13:38:23 +0100 |
|---|---|---|
| committer | Joakim Hulthe <joakim.hulthe@mullvad.net> | 2025-02-24 10:19:39 +0100 |
| commit | 563cc5707c874c91afe2c6b79829ba62557b143d (patch) | |
| tree | 4a4bb9053d23bd08d037fe2aecb85ee8db2c8c0a | |
| parent | 14da40a2b45d82bfa8011ead8fd2eb5f7fbbac68 (diff) | |
| download | mullvadvpn-563cc5707c874c91afe2c6b79829ba62557b143d.tar.xz mullvadvpn-563cc5707c874c91afe2c6b79829ba62557b143d.zip | |
Set exception logging file on Android
| -rw-r--r-- | mullvad-jni/src/lib.rs | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/mullvad-jni/src/lib.rs b/mullvad-jni/src/lib.rs index acced273a3..a82acd3628 100644 --- a/mullvad-jni/src/lib.rs +++ b/mullvad-jni/src/lib.rs @@ -17,7 +17,9 @@ use mullvad_daemon::{ DaemonCommandChannel, DaemonCommandSender, DaemonConfig, }; use std::{ + ffi::CString, io, + os::unix::ffi::OsStrExt, path::{Path, PathBuf}, sync::{Arc, Mutex, Once, OnceLock}, }; @@ -215,16 +217,21 @@ async fn spawn_daemon_inner( fn start_logging(log_dir: &Path) -> Result<(), String> { static LOGGER_RESULT: OnceLock<Result<(), String>> = OnceLock::new(); LOGGER_RESULT - .get_or_init(|| start_logging_inner(log_dir).map_err(|e| e.display_chain())) + .get_or_init(|| start_logging_inner(log_dir)) .to_owned() } -fn start_logging_inner(log_dir: &Path) -> Result<(), logging::Error> { +fn start_logging_inner(log_dir: &Path) -> Result<(), String> { let log_file = log_dir.join(LOG_FILENAME); - logging::init_logger(log::LevelFilter::Debug, Some(&log_file), true)?; - exception_logging::enable(); + logging::init_logger(log::LevelFilter::Debug, Some(&log_file), true) + .map_err(|e| e.display_chain())?; log_panics::init(); + exception_logging::set_log_file( + CString::new(log_file.as_os_str().as_bytes()) + .map_err(|_| "Log file path contained interior null bytes: {log_file:?}")?, + ); + exception_logging::enable(); Ok(()) } |
