mirror of
https://github.com/vale981/stream
synced 2025-03-05 18:11:39 -05:00
nicer logging output
This commit is contained in:
parent
4764f4c1d5
commit
29642bb669
4 changed files with 40 additions and 4 deletions
|
@ -4,13 +4,14 @@
|
||||||
:license {:name "EPL-2.0 OR GPL-2.0-or-later WITH Classpath-exception-2.0"
|
:license {:name "EPL-2.0 OR GPL-2.0-or-later WITH Classpath-exception-2.0"
|
||||||
:url "https://www.eclipse.org/legal/epl-2.0/"}
|
:url "https://www.eclipse.org/legal/epl-2.0/"}
|
||||||
:dependencies [[org.clojure/clojure "1.10.1"]
|
:dependencies [[org.clojure/clojure "1.10.1"]
|
||||||
[com.github.thjomnx/java-systemd "1.1.0"]
|
[com.github.thjomnx/java-systemd "1.2.0-SNAPSHOT"]
|
||||||
[com.taoensso/timbre "4.10.0"]
|
[com.taoensso/timbre "4.10.0"]
|
||||||
[cljstache/cljstache "2.0.6"]
|
[cljstache/cljstache "2.0.6"]
|
||||||
[org.clojure/core.async "1.2.603"]
|
[org.clojure/core.async "1.2.603"]
|
||||||
[slingshot "0.12.2"]
|
[slingshot "0.12.2"]
|
||||||
;; [com.github.hypfvieh/dbus-java "3.2.1"]
|
;; [com.github.hypfvieh/dbus-java "3.2.1"]
|
||||||
]
|
|
||||||
|
[com.taoensso/encore "2.122.0"]]
|
||||||
:main ^:skip-aot stream.core
|
:main ^:skip-aot stream.core
|
||||||
:target-path "target/%s"
|
:target-path "target/%s"
|
||||||
:profiles {:uberjar {:aot :all}})
|
:profiles {:uberjar {:aot :all}})
|
||||||
|
|
|
@ -100,7 +100,6 @@
|
||||||
(let [{:keys [unit-name monitor]} proc
|
(let [{:keys [unit-name monitor]} proc
|
||||||
[_ close] monitor]
|
[_ close] monitor]
|
||||||
(sys/remove-service! unit-name)
|
(sys/remove-service! unit-name)
|
||||||
(println close)
|
|
||||||
(close)
|
(close)
|
||||||
(dosync (commute processes dissoc id))
|
(dosync (commute processes dissoc id))
|
||||||
true)
|
true)
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
(ns stream.core
|
(ns stream.core
|
||||||
(:gen-class))
|
(:gen-class)
|
||||||
|
(:require [stream.util.logging]))
|
||||||
|
|
||||||
(defn -main
|
(defn -main
|
||||||
"I don't do a whole lot ... yet."
|
"I don't do a whole lot ... yet."
|
||||||
|
|
35
src/stream/util/logging.clj
Normal file
35
src/stream/util/logging.clj
Normal file
|
@ -0,0 +1,35 @@
|
||||||
|
(ns stream.util.logging
|
||||||
|
(:require [taoensso.timbre :refer :all]
|
||||||
|
[clojure.string :as str]
|
||||||
|
[taoensso.encore :as enc :refer [have have? qb]]))
|
||||||
|
|
||||||
|
(defn color-output-fn
|
||||||
|
"Default (fn [data]) -> string output fn.
|
||||||
|
Use`(partial default-output-fn <opts-map>)` to modify default opts."
|
||||||
|
([ data] (color-output-fn nil data))
|
||||||
|
([opts data] ; For partials
|
||||||
|
(let [{:keys [no-stacktrace? stacktrace-fonts]} opts
|
||||||
|
{:keys [level ?err #_vargs msg_ ?ns-str ?file hostname_
|
||||||
|
timestamp_ ?line]} data
|
||||||
|
colors {:debug :cyan, :info :green, :warn :yellow
|
||||||
|
:error :red, :fatal :purple, :report :blue}
|
||||||
|
level-str (str/lower-case (name level))]
|
||||||
|
(str
|
||||||
|
(color-str :white (force timestamp_))
|
||||||
|
" - "
|
||||||
|
""
|
||||||
|
(if-let [color (colors level)]
|
||||||
|
(color-str color level-str)
|
||||||
|
level-str)
|
||||||
|
": "
|
||||||
|
(color-str :black (force msg_))
|
||||||
|
(if (= level :debug)
|
||||||
|
(str " - [" (or ?ns-str ?file "?") ":" (or ?line "?") "]"))
|
||||||
|
(when-not no-stacktrace?
|
||||||
|
(when-let [err ?err]
|
||||||
|
(str enc/system-newline (stacktrace err opts))))))))
|
||||||
|
|
||||||
|
(let [colors {:debug :cyan, :info :green, :warn :yellow, :error :red, :fatal :purple, :report :blue}]
|
||||||
|
(merge-config!
|
||||||
|
{:level :debug
|
||||||
|
:output-fn color-output-fn}))
|
Loading…
Add table
Reference in a new issue