advisory-circular/src/main/lemondronor/circlebot/logging.cljs

38 lines
1.4 KiB
Plaintext
Raw Normal View History

2019-12-14 07:50:19 +00:00
(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
2019-12-14 10:39:06 +00:00
#js {:level "info"
2019-12-14 07:50:19 +00:00
: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}))