diff options
| author | Linus Färnstrand <linus@mullvad.net> | 2017-03-07 10:12:45 +0100 |
|---|---|---|
| committer | Linus Färnstrand <linus@mullvad.net> | 2017-03-07 10:12:45 +0100 |
| commit | 6ab1a2e6fda4b9a9acff75765de91d2e3dc839e1 (patch) | |
| tree | c1692eba868902d51e1c8178a44505d82ebc114a | |
| parent | 3af0e735feaf6b4d52af9603141b84392037bbb1 (diff) | |
| download | mullvadvpn-6ab1a2e6fda4b9a9acff75765de91d2e3dc839e1.tar.xz mullvadvpn-6ab1a2e6fda4b9a9acff75765de91d2e3dc839e1.zip | |
Add logging to talpid_cli
| -rw-r--r-- | Cargo.lock | 2 | ||||
| -rw-r--r-- | talpid_cli/Cargo.toml | 2 | ||||
| -rw-r--r-- | talpid_cli/src/main.rs | 12 |
3 files changed, 16 insertions, 0 deletions
diff --git a/Cargo.lock b/Cargo.lock index de49082f8d..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", ] 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) |
