From e0f2c4e0aab1286ef2209542a37cbc123eae8497 Mon Sep 17 00:00:00 2001 From: Andrey Antukh Date: Mon, 29 Jul 2024 16:16:39 +0200 Subject: [PATCH] :sparkles: Add the ability to pass body to a log entry --- common/src/app/common/logging.cljc | 25 ++++++++++++++++++++----- 1 file changed, 20 insertions(+), 5 deletions(-) diff --git a/common/src/app/common/logging.cljc b/common/src/app/common/logging.cljc index d7780ef70e..f1eaee79d8 100644 --- a/common/src/app/common/logging.cljc +++ b/common/src/app/common/logging.cljc @@ -153,14 +153,29 @@ (defn build-message [props] (loop [props (seq props) - result []] + result [] + body nil] (if-let [[k v] (first props)] - (if (simple-ident? k) + (cond + (simple-ident? k) (recur (next props) - (conj result (str (name k) "=" (pr-str v)))) + (conj result (str (name k) "=" (pr-str v))) + body) + + (= ::body k) (recur (next props) - result)) - (str/join ", " result)))) + result + v) + + :else + (recur (next props) + result + body)) + + (let [message (str/join ", " result)] + (if (string? body) + (str message "\n" body) + message))))) (defn build-stack-trace [cause]