From 6a4ed2d9eb1a14796b6983a95cbb966ac10298b8 Mon Sep 17 00:00:00 2001 From: Sdogruyol Date: Mon, 4 Jan 2016 21:54:58 +0200 Subject: [PATCH] Add exception logging. Closes #41 --- src/kemal/handler.cr | 1 + src/kemal/logger.cr | 1 + 2 files changed, 2 insertions(+) diff --git a/src/kemal/handler.cr b/src/kemal/handler.cr index a28e21b..0ac9f90 100644 --- a/src/kemal/handler.cr +++ b/src/kemal/handler.cr @@ -33,6 +33,7 @@ class Kemal::Handler < HTTP::Handler body = route.handler.call(context).to_s return HTTP::Response.new(context.status_code, body, context.response_headers) rescue ex + Kemal::Logger::INSTANCE.write "Exception: #{ex.to_s}\n" return render_500(ex.to_s) end end diff --git a/src/kemal/logger.cr b/src/kemal/logger.cr index bf01038..622e275 100644 --- a/src/kemal/logger.cr +++ b/src/kemal/logger.cr @@ -1,6 +1,7 @@ require "colorize" class Kemal::Logger < HTTP::Handler + INSTANCE = new getter handler def initialize