Skip to content

Commit

Permalink
Improve formatting of mulog events
Browse files Browse the repository at this point in the history
  • Loading branch information
Ramblurr committed May 16, 2024
1 parent ac7b79f commit c56e69f
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 8 deletions.
1 change: 1 addition & 0 deletions .clj-kondo/config.edn
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{:skip-comments true
:lint-as {io.pedestal.interceptor.error/error-dispatch clj-kondo.lint-as/def-catch-all}
:linters {:unused-value {:level :off}
:unused-binding {:level :off}
:unused-import {:level :off}
Expand Down
2 changes: 2 additions & 0 deletions resources/config.edn
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
{:name "SNOrga"
:git-hash #or [#env GIT_HASH "unknown"]
:build-date #or [#env BUILD_DATE "unknown"]
:secrets #include #or [#env APP_SECRETS_FILE "../secrets.edn"]
:admin-email #ref [:secrets :admin-email]
:app-base-url #ref [:secrets :app-base-url]
Expand Down
10 changes: 5 additions & 5 deletions src/clj/app/errors.clj
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
(ns app.errors
(:require
[medley.core :as m]
[com.brunobonacci.mulog :as μ]
[app.config :as config]
[app.util :as util]
[clojure.set :as set]))
[com.brunobonacci.mulog :as μ]
[medley.core :as m]))

(def dangerous-keys
#{:datomic-conn
Expand Down Expand Up @@ -67,9 +66,10 @@
(assoc :will-change-lang (:will-change-lang req))
(assoc :form-params (:form-params req))
(assoc :path-params (:path-params req)))))
(update :request-method name)
;; (update :request-method name)
(select-keys [:uri :query-string :request-method :headers :params :member-id :user-email])
(set/rename-keys {:request-method :method :params :data :uri :url})))
;; (set/rename-keys {:request-method :method :params :data :uri :url})
))

(defn send-event!
"Sends a telemetry event asynchronously"
Expand Down
7 changes: 6 additions & 1 deletion src/clj/app/ig.clj
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,12 @@
profile)

(defmethod ig/init-key ::env [_ profile]
(system/config profile))
(let [env (system/config profile)]
(μ/set-global-context! {:app-name (:name env)
:git-hash (:git-hash env)
:build-date (:build-date env)
:env (-> env :ig/system :app.ig/profile)})
env))

(defmethod ig/init-key ::handler [_ system]
(routes/default-handler system))
Expand Down
3 changes: 1 addition & 2 deletions src/clj/app/interceptors.clj
Original file line number Diff line number Diff line change
Expand Up @@ -161,9 +161,8 @@
user-email (auth/get-current-email req)
finish (System/currentTimeMillis)
total (- finish start-time)]

(μ/log :http/request :msg "request completed"
:method (str/upper-case (name request-method))
:request-method request-method
:uri uri
:human-id human-id
:user-email user-email
Expand Down

0 comments on commit c56e69f

Please sign in to comment.