diff options
| author | Teddy Wing | 2017-11-12 20:50:52 +0100 | 
|---|---|---|
| committer | Teddy Wing | 2017-11-12 20:50:52 +0100 | 
| commit | 09adc073ef92c33ee63c1885cf7888cbfead4f0e (patch) | |
| tree | 33e1b2c33c469310b6f32de9c0043b5c3623e920 /src | |
| parent | 98fb0777107ed24e95cb3012a8b10ee3228829d5 (diff) | |
| download | kipper-09adc073ef92c33ee63c1885cf7888cbfead4f0e.tar.bz2 | |
main(): Add logging
Initialise a new 'stderrlog' and log all errors to the log.
Diffstat (limited to 'src')
| -rw-r--r-- | src/main.rs | 22 | 
1 files changed, 20 insertions, 2 deletions
| diff --git a/src/main.rs b/src/main.rs index 3f3351a..3a6ee6c 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,5 +1,8 @@  extern crate getopts;  #[macro_use] +extern crate log; +extern crate stderrlog; +#[macro_use]  extern crate rouille;  extern crate kipper; @@ -87,6 +90,13 @@ fn main() {          None => DEFAULT_PORT,      }; +    // Logging +    stderrlog::new() +        .module(module_path!()) +        .timestamp(stderrlog::Timestamp::Second) +        .init() +        .expect("Logger failed to initialise"); +      rouille::start_server(format!("localhost:{}", port), move |request| {          router!(request,              (POST) (/github/pull_request_event) => { @@ -100,7 +110,11 @@ fn main() {                          let commit_ref = match CommitRef::new(body.as_ref()) {                              Ok(cr) => cr, -                            Err(_) => return internal_server_error(), +                            Err(e) => { +                                error!("{}", e.to_string()); + +                                return internal_server_error() +                            },                          };                          match jenkins::find_and_track_build_and_update_status( @@ -111,7 +125,11 @@ fn main() {                              github_token.clone(),                          ) {                              Ok(_) => {}, -                            Err(_) => return internal_server_error(), +                            Err(e) => { +                                error!("{}", e.to_string()); + +                                return internal_server_error() +                            },                          };                          rouille::Response::text("202 Accepted") | 
