diff options
| author | Linus Färnstrand <linus@mullvad.net> | 2017-03-07 10:20:04 +0100 |
|---|---|---|
| committer | Linus Färnstrand <linus@mullvad.net> | 2017-03-07 10:20:04 +0100 |
| commit | 79836cdcddff32feb1c30e0e7035f94ffc16053f (patch) | |
| tree | c1692eba868902d51e1c8178a44505d82ebc114a | |
| parent | f3b45296b9d1decbc737698e3ad34ac9b75d5130 (diff) | |
| parent | 6ab1a2e6fda4b9a9acff75765de91d2e3dc839e1 (diff) | |
| download | mullvadvpn-79836cdcddff32feb1c30e0e7035f94ffc16053f.tar.xz mullvadvpn-79836cdcddff32feb1c30e0e7035f94ffc16053f.zip | |
Merge branch 'more-logging'
| -rw-r--r-- | Cargo.lock | 4 | ||||
| -rw-r--r-- | Cargo.toml | 1 | ||||
| -rw-r--r-- | src/lib.rs | 3 | ||||
| -rw-r--r-- | src/process/openvpn.rs | 1 | ||||
| -rw-r--r-- | talpid_cli/Cargo.toml | 2 | ||||
| -rw-r--r-- | talpid_cli/src/main.rs | 12 | ||||
| -rw-r--r-- | talpid_ipc/Cargo.toml | 1 | ||||
| -rw-r--r-- | talpid_ipc/src/lib.rs | 2 | ||||
| -rw-r--r-- | talpid_ipc/src/zmq_ipc.rs | 2 |
9 files changed, 28 insertions, 0 deletions
diff --git a/Cargo.lock b/Cargo.lock index d6c53e865c..573b2efb2e 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -275,7 +275,9 @@ name = "talpid_cli" version = "0.0.0" dependencies = [ "clap 2.20.3 (registry+https://github.com/rust-lang/crates.io-index)", + "env_logger 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)", "error-chain 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", "talpid_core 0.0.0", ] @@ -286,6 +288,7 @@ dependencies = [ "assert_matches 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)", "clonablechild 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", "error-chain 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", "openvpn_ffi 0.1.0", "talpid_ipc 0.1.0", "zmq 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)", @@ -297,6 +300,7 @@ version = "0.1.0" dependencies = [ "assert_matches 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)", "error-chain 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", "serde 0.9.11 (registry+https://github.com/rust-lang/crates.io-index)", "serde_json 0.9.9 (registry+https://github.com/rust-lang/crates.io-index)", "zmq 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)", diff --git a/Cargo.toml b/Cargo.toml index a2271237ab..9787050779 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -7,6 +7,7 @@ description = "Core backend functionality of the Mullvad VPN client" [dependencies] clonablechild = "0.1" error-chain = "0.8" +log = "0.3" [dependencies.talpid_ipc] path = "talpid_ipc" diff --git a/src/lib.rs b/src/lib.rs index 00c4061801..8fe76a5a69 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -9,6 +9,9 @@ extern crate assert_matches; extern crate clonablechild; #[macro_use] +extern crate log; + +#[macro_use] extern crate error_chain; extern crate talpid_ipc; diff --git a/src/process/openvpn.rs b/src/process/openvpn.rs index b533b32b67..48da508f75 100644 --- a/src/process/openvpn.rs +++ b/src/process/openvpn.rs @@ -84,6 +84,7 @@ impl OpenVpnCommand { let mut command = self.create_command(); let args = self.get_arguments(); command.args(&args); + debug!("Spawning: {}", &self); command.spawn() } diff --git a/talpid_cli/Cargo.toml b/talpid_cli/Cargo.toml index 617a60e340..bc2111bb0d 100644 --- a/talpid_cli/Cargo.toml +++ b/talpid_cli/Cargo.toml @@ -7,6 +7,8 @@ description = "Run Talpid easily from the command line" [dependencies] clap = "2.20" error-chain = "0.8" +log = "0.3" +env_logger = "0.4" [dependencies.talpid_core] path = "../" diff --git a/talpid_cli/src/main.rs b/talpid_cli/src/main.rs index dfc13b74d5..ae8be2eed5 100644 --- a/talpid_cli/src/main.rs +++ b/talpid_cli/src/main.rs @@ -6,6 +6,8 @@ extern crate talpid_core; extern crate clap; #[macro_use] extern crate error_chain; +extern crate log; +extern crate env_logger; use std::io::{self, Read, Write}; use std::sync::mpsc::{self, Receiver}; @@ -19,6 +21,11 @@ use cli::Args; error_chain! { + errors { + InitLoggingFailed { + description("Failed to bootstrap logging system") + } + } links { Monitor(talpid_core::process::openvpn::Error, talpid_core::process::openvpn::ErrorKind); } @@ -39,12 +46,17 @@ fn main() { } fn run() -> Result<()> { + init_logger()?; let args = cli::parse_args_or_exit(); let command = create_openvpn_command(&args); let monitor = OpenVpnMonitor::new(command); main_loop(monitor) } +pub fn init_logger() -> Result<()> { + env_logger::init().chain_err(|| ErrorKind::InitLoggingFailed) +} + fn create_openvpn_command(args: &Args) -> OpenVpnCommand { let mut command = OpenVpnCommand::new(&args.binary); command.config(&args.config) diff --git a/talpid_ipc/Cargo.toml b/talpid_ipc/Cargo.toml index 369abcb128..12126ed3fc 100644 --- a/talpid_ipc/Cargo.toml +++ b/talpid_ipc/Cargo.toml @@ -8,6 +8,7 @@ description = "IPC client and server for talpid" error-chain = "0.8" serde = "0.9" serde_json = "0.9" +log = "0.3" [target.'cfg(not(windows))'.dependencies] zmq = "0.8" diff --git a/talpid_ipc/src/lib.rs b/talpid_ipc/src/lib.rs index 8698adb55c..8f82417d58 100644 --- a/talpid_ipc/src/lib.rs +++ b/talpid_ipc/src/lib.rs @@ -1,5 +1,7 @@ #[macro_use] extern crate error_chain; +#[macro_use] +extern crate log; extern crate serde; diff --git a/talpid_ipc/src/zmq_ipc.rs b/talpid_ipc/src/zmq_ipc.rs index f0111af254..aeecf2be41 100644 --- a/talpid_ipc/src/zmq_ipc.rs +++ b/talpid_ipc/src/zmq_ipc.rs @@ -23,6 +23,7 @@ pub fn start_new_server<T, F>(on_message: F) -> Result<IpcServerId> let connection_string = format!("tcp://127.0.0.1:{}", port); if let Ok(socket) = start_zmq_server(&connection_string) { let _ = start_receive_loop(socket, on_message); + debug!("Listening on {}", connection_string); return Ok(connection_string); } } @@ -96,6 +97,7 @@ impl<T> IpcClient<T> } fn connect(&mut self) -> Result<()> { + debug!("Trying to establish connection to {}", self.server_id); let ctx = zmq::Context::new(); let socket = ctx.socket(zmq::PUSH) .chain_err(|| "Could not create ZeroMQ PUSH socket".to_owned())?; |
