diff options
author | Andreas Tolfsen <ato@mozilla.com> | 2016-09-07 17:50:00 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-09-07 17:50:00 +0300 |
commit | acfde732fe4381e63b7e17664c92de9eb339ddfc (patch) | |
tree | 2184418f09884f91f351ac612cc26bb4cb8e1cbf /src | |
parent | 007939ed7f182e160f72d5e312fd1891d628b8c7 (diff) | |
parent | e61b8c4cea666c035e611125298ae5e044251901 (diff) |
Merge pull request #218 from andreastt/print-listening
Log listening host and port
Diffstat (limited to 'src')
-rw-r--r-- | src/main.rs | 30 |
1 files changed, 13 insertions, 17 deletions
diff --git a/src/main.rs b/src/main.rs index ef9553e..8a3e206 100644 --- a/src/main.rs +++ b/src/main.rs @@ -87,11 +87,6 @@ fn app<'a, 'b>() -> App<'a, 'b> { .help("Prints version and copying information")) } -fn print_err(reason: &str) { - let prog = std::env::args().next().unwrap_or("geckodriver".to_owned()); - let _ = writeln!(&mut ::std::io::stderr(), "{}: error: {}", prog, reason); -} - fn run() -> ProgramResult { let matches = app().get_matches(); @@ -128,16 +123,15 @@ You can obtain a copy of the license at https://mozilla.org/MPL/2.0/."); // overrides defaults in Gecko // which are info for optimised builds // and debug for debug builds - let log_level = - if matches.is_present("log_level") { - LogLevel::from_str(matches.value_of("log_level").unwrap()).ok() - } else { - match matches.occurrences_of("v") { - 0 => None, - 1 => Some(LogLevel::Debug), - _ => Some(LogLevel::Trace), - } - }; + let log_level = if matches.is_present("log_level") { + LogLevel::from_str(matches.value_of("log_level").unwrap()).ok() + } else { + match matches.occurrences_of("verbosity") { + 0 => None, + 1 => Some(LogLevel::Debug), + _ => Some(LogLevel::Trace), + } + }; let settings = MarionetteSettings { port: marionette_port, @@ -147,7 +141,9 @@ You can obtain a copy of the license at https://mozilla.org/MPL/2.0/."); }; let handler = MarionetteHandler::new(settings); - webdriver::server::start(addr, handler, extension_routes()); + let listening = try!(webdriver::server::start(addr, handler, extension_routes()) + .or(Err((ExitCode::Usage, "Invalid host address".to_owned())))); + info!("Listening on {}", listening.socket); Ok(()) } @@ -158,7 +154,7 @@ fn main() { let exit_code = match run() { Ok(_) => ExitCode::Ok, Err((exit_code, reason)) => { - print_err(&reason.to_string()); + error!("{}", reason); exit_code }, }; |