make logging loki compatable
This commit is contained in:
parent
8263c09b50
commit
edc74be72b
3 changed files with 35 additions and 2 deletions
|
|
@ -11,7 +11,6 @@
|
||||||
:mastodon-account-id "MASTODON_ACCOUNT_ID"})
|
:mastodon-account-id "MASTODON_ACCOUNT_ID"})
|
||||||
|
|
||||||
(defn- load-config []
|
(defn- load-config []
|
||||||
(tel/log! :info "Config is being loaded")
|
|
||||||
(merge (read-string (slurp "config.edn"))
|
(merge (read-string (slurp "config.edn"))
|
||||||
(into {} (for [[k env-var] env-overrides
|
(into {} (for [[k env-var] env-overrides
|
||||||
:let [env-val (System/getenv env-var)]
|
:let [env-val (System/getenv env-var)]
|
||||||
|
|
|
||||||
31
src/micro_blog/logging.clj
Normal file
31
src/micro_blog/logging.clj
Normal file
|
|
@ -0,0 +1,31 @@
|
||||||
|
(ns micro-blog.logging
|
||||||
|
(:import [java.time Instant])
|
||||||
|
(:require
|
||||||
|
[taoensso.telemere :as tel]
|
||||||
|
[cheshire.core :as json]
|
||||||
|
[cheshire.generate :as gen]))
|
||||||
|
|
||||||
|
(def json-logging-handler
|
||||||
|
(tel/handler:console
|
||||||
|
{:output-fn
|
||||||
|
(tel/pr-signal-fn
|
||||||
|
{:clean-fn (fn [signal]
|
||||||
|
(-> signal
|
||||||
|
(assoc :message (get signal :msg_))
|
||||||
|
(dissoc :kind :msg_ :schema
|
||||||
|
:run-val
|
||||||
|
:kvs :end-inst :run-form :sample :_otel-context
|
||||||
|
:root :thread :run-nsecs :parent)))
|
||||||
|
:pr-fn json/generate-string})}))
|
||||||
|
|
||||||
|
(gen/add-encoder Instant
|
||||||
|
(fn [c jsonGenerator]
|
||||||
|
(.writeString jsonGenerator (.toString c))))
|
||||||
|
|
||||||
|
(defn setup-logging []
|
||||||
|
(tel/remove-handler! :default/console)
|
||||||
|
(tel/add-handler! ::json-logger json-logging-handler))
|
||||||
|
|
||||||
|
(defn test-logging []
|
||||||
|
(setup-logging)
|
||||||
|
(tel/log! {:level :info :data {:thing "example"}} "This is a test log message"))
|
||||||
|
|
@ -3,6 +3,7 @@
|
||||||
(:import [java.time Instant Duration])
|
(:import [java.time Instant Duration])
|
||||||
(:require [chime.core :as chime]
|
(:require [chime.core :as chime]
|
||||||
[taoensso.telemere :as tel]
|
[taoensso.telemere :as tel]
|
||||||
|
[micro-blog.logging]
|
||||||
[micro-blog.blue-sky :as blue-sky]
|
[micro-blog.blue-sky :as blue-sky]
|
||||||
[micro-blog.mastodon :as masto]))
|
[micro-blog.mastodon :as masto]))
|
||||||
|
|
||||||
|
|
@ -10,10 +11,12 @@
|
||||||
masto/run])
|
masto/run])
|
||||||
|
|
||||||
(defn -main []
|
(defn -main []
|
||||||
|
(micro-blog.logging/setup-logging)
|
||||||
(tel/log! :info "Setting up crons")
|
(tel/log! :info "Setting up crons")
|
||||||
(doseq [[i cron] (map-indexed vector crons)]
|
(doseq [[i cron] (map-indexed vector crons)]
|
||||||
(let [start (.plus (Instant/now) (Duration/ofMinutes (* i 5)))]
|
(let [start (.plus (Instant/now) (Duration/ofMinutes (* i 5)))]
|
||||||
(chime/chime-at (chime/periodic-seq start (Duration/ofMinutes 30))
|
(chime/chime-at (chime/periodic-seq start (Duration/ofMinutes 30))
|
||||||
(fn [_time]
|
(fn [_time]
|
||||||
(cron)))))
|
(cron)))))
|
||||||
@(promise))
|
@(promise)
|
||||||
|
(tel/stop-handlers!))
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue