summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorJanito Vaqueiro Ferreira Filho <janito@mullvad.net>2019-07-24 15:05:52 +0000
committerJanito Vaqueiro Ferreira Filho <janito@mullvad.net>2019-07-24 15:05:52 +0000
commit0f8c5da08e5054558cd853c28bad995a4a91cfc9 (patch)
tree7367ef79dc07a266a73e399bf0c76c4c4fc006d6
parent17af4d0db6eb48c6800819bb75767882672f8df5 (diff)
downloadmullvadvpn-0f8c5da08e5054558cd853c28bad995a4a91cfc9.tar.xz
mullvadvpn-0f8c5da08e5054558cd853c28bad995a4a91cfc9.zip
Only configure logging once
-rw-r--r--mullvad-jni/src/lib.rs12
1 files changed, 7 insertions, 5 deletions
diff --git a/mullvad-jni/src/lib.rs b/mullvad-jni/src/lib.rs
index 48017a8534..3feb157745 100644
--- a/mullvad-jni/src/lib.rs
+++ b/mullvad-jni/src/lib.rs
@@ -69,6 +69,8 @@ const CLASSES_TO_LOAD: &[&str] = &[
];
lazy_static! {
+ static ref LOG_INIT_RESULT: Result<PathBuf, String> =
+ start_logging().map_err(|error| error.display_chain());
static ref DAEMON_INTERFACE: DaemonInterface = DaemonInterface::new();
static ref CLASSES: RwLock<HashMap<&'static str, GlobalRef>> =
RwLock::new(HashMap::with_capacity(CLASSES_TO_LOAD.len()));
@@ -102,16 +104,16 @@ pub extern "system" fn Java_net_mullvad_mullvadvpn_MullvadDaemon_initialize(
this: JObject,
vpnService: JObject,
) {
- match start_logging() {
- Ok(log_dir) => {
+ match *LOG_INIT_RESULT {
+ Ok(ref log_dir) => {
load_classes(&env);
- if let Err(error) = initialize(&env, &this, &vpnService, log_dir) {
+ if let Err(error) = initialize(&env, &this, &vpnService, log_dir.clone()) {
log::error!("{}", error.display_chain());
}
}
- Err(error) => env
- .throw(error.display_chain())
+ Err(ref message) => env
+ .throw(message.as_str())
.expect("Failed to throw exception"),
}
}