diff options
| -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) |
