aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorTeddy Wing2017-11-12 20:50:52 +0100
committerTeddy Wing2017-11-12 20:50:52 +0100
commit09adc073ef92c33ee63c1885cf7888cbfead4f0e (patch)
tree33e1b2c33c469310b6f32de9c0043b5c3623e920 /src
parent98fb0777107ed24e95cb3012a8b10ee3228829d5 (diff)
downloadkipper-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.rs22
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")