dont really care for rotor mainly due to it putting ansi codes into logs
This commit is contained in:
parent
b990ebd7ce
commit
23a67b0027
|
@ -12,25 +12,18 @@
|
||||||
[blarg.views.layout :as layout]
|
[blarg.views.layout :as layout]
|
||||||
[blarg.models.db :as db]
|
[blarg.models.db :as db]
|
||||||
[blarg.routes.accessrules :refer [auth-required]]
|
[blarg.routes.accessrules :refer [auth-required]]
|
||||||
[blarg.route-utils :refer [find-routes]]))
|
[blarg.route-utils :refer [find-routes]]
|
||||||
|
[blarg.util :refer [log-formatter]]))
|
||||||
|
|
||||||
(defroutes app-routes
|
(defroutes app-routes
|
||||||
(route/resources "/")
|
(route/resources "/")
|
||||||
(layout/render-handler "notfound.html" :status 404))
|
(layout/render-handler "notfound.html" :status 404))
|
||||||
|
|
||||||
(defn init []
|
(defn init []
|
||||||
(timbre/set-config!
|
(timbre/set-config! [:shared-appender-config :spit-filename] "blarg.log")
|
||||||
[:appenders :rotor]
|
(timbre/set-config! [:appenders :spit :enabled?] true)
|
||||||
{:min-level :info
|
(timbre/set-config! [:fmt-output-fn] log-formatter)
|
||||||
:enabled? true
|
|
||||||
:async? false ; should be always false for rotor
|
|
||||||
:max-message-per-msecs nil
|
|
||||||
:fn rotor/appender-fn})
|
|
||||||
|
|
||||||
(timbre/set-config!
|
|
||||||
[:shared-appender-config :rotor]
|
|
||||||
{:path "blarg.log" :max-size (* 512 1024) :backlog 10})
|
|
||||||
|
|
||||||
(timbre/info "blarg started successfully")
|
(timbre/info "blarg started successfully")
|
||||||
|
|
||||||
(when (= "DEV" (config-val :env))
|
(when (= "DEV" (config-val :env))
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
(ns blarg.util
|
(ns blarg.util
|
||||||
(:require [clojure.java.io :as io]
|
(:require [clojure.string :as str]
|
||||||
|
[clojure.java.io :as io]
|
||||||
|
[clojure.stacktrace :refer [print-stack-trace]]
|
||||||
[markdown.core :as md]
|
[markdown.core :as md]
|
||||||
[noir.io]
|
[noir.io]
|
||||||
[cheshire.core :refer :all])
|
[cheshire.core :refer :all])
|
||||||
|
@ -59,3 +61,13 @@
|
||||||
|
|
||||||
(defn ensure-prefix-suffix [s affix]
|
(defn ensure-prefix-suffix [s affix]
|
||||||
(ensure-prefix (ensure-suffix s affix) affix))
|
(ensure-prefix (ensure-suffix s affix) affix))
|
||||||
|
|
||||||
|
(defn get-throwable-stack-trace [throwable]
|
||||||
|
(if throwable
|
||||||
|
(with-out-str
|
||||||
|
(print-stack-trace throwable))))
|
||||||
|
|
||||||
|
(defn log-formatter [{:keys [level throwable message timestamp hostname ns]} & [{:keys [nofonts?] :as appender-fmt-output-opts}]]
|
||||||
|
(format "%s %s %s [%s] - %s%s"
|
||||||
|
timestamp hostname (-> level name str/upper-case) ns (or message "")
|
||||||
|
(or (get-throwable-stack-trace throwable) "")))
|
Reference in a new issue