From b39630d9a7133c58ba493cbd568cccba968a36bd Mon Sep 17 00:00:00 2001 From: Marcin Kulik Date: Thu, 2 Mar 2017 11:53:43 +0100 Subject: [PATCH] Log errors with clojure.tools.logging/error --- src/asciinema/yada.clj | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/asciinema/yada.clj b/src/asciinema/yada.clj index e2dafcc..58baf6d 100644 --- a/src/asciinema/yada.clj +++ b/src/asciinema/yada.clj @@ -1,5 +1,6 @@ (ns asciinema.yada (:require [clojure.java.io :as io] + [clojure.tools.logging :as log] [yada.yada :as yada])) (def not-found-model @@ -13,7 +14,13 @@ "text/html" (io/input-stream (io/resource "asciinema/errors/404.html")) "Not found")))}) +(defn logger [ctx] + (when-let [error (:error ctx)] + (when (= (-> ctx :response :status) 500) + (log/error error)))) + (defn resource [model] (-> model + (assoc :logger logger) (update-in [:responses 404] #(or % not-found-model)) yada/resource))