38 lines
1.4 KiB
Clojure
38 lines
1.4 KiB
Clojure
(ns lemondronor.circlebot.logging
|
|
(:require
|
|
[goog.string :as gstring]
|
|
goog.string.format
|
|
["winston" :as winston])
|
|
(:require-macros
|
|
[lemondronor.circlebot.logging]))
|
|
|
|
(let [createLogger (.-createLogger winston)
|
|
format (.-format winston)
|
|
transports (.-transports winston)
|
|
printf-fmt #(gstring/format "%s%-7s %-9s/%-18s| %s"
|
|
(.-timestamp %)
|
|
(.-ms %)
|
|
(.-service %)
|
|
(.-level %)
|
|
(.-message %))]
|
|
(def logger (createLogger
|
|
#js {:level "info"
|
|
:format (.combine
|
|
format
|
|
(.colorize format #js {:all true})
|
|
(.timestamp format #js {:format "YYYYMMDD HHmmss"})
|
|
(.errors format #js {:stack true})
|
|
(.splat format)
|
|
(.timestamp format)
|
|
(.label format)
|
|
(.ms format)
|
|
(.json format))
|
|
:defaultMeta #js {}}))
|
|
(.add logger (new (.-Console transports)
|
|
#js {:format (.combine format
|
|
(.printf format printf-fmt))})))
|
|
|
|
|
|
(defn get-logger [service]
|
|
(.child logger #js {:service service}))
|