Skip to content

Commit

Permalink
Production fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Kaspazza committed Jan 3, 2024
1 parent cc72412 commit 5853e7d
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 6 deletions.
7 changes: 6 additions & 1 deletion src/clj/automaton_core/log/be_log.clj
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,12 @@
(defn- logger-ids-to-logger-fns
"Based on logger-id chooses from registered strategies which logging function to use."
[logger-ids]
(reduce (fn [acc logger-id] (conj acc (get-in log-be-registry/strategies-registry [logger-id :impl]))) [] logger-ids))
(reduce (fn [acc logger-id]
(if-let [logger-strategy (get-in log-be-registry/strategies-registry [logger-id :impl])]
(conj acc logger-strategy)
(do (print "WARN: Logging strategy is nil for id: " logger-id) acc)))
[]
logger-ids))

(defmacro log
[logger-ids level & message]
Expand Down
4 changes: 2 additions & 2 deletions src/clj/automaton_core/log/be_registry.clj
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
:impl automaton-core.log.impl.log4j2/log-fn}
::log-registry/no-op {:description "Deactivate that log"
:impl no-op-fn}
::log-registry/error-tracking {:description "For monitoring exceptions in the application"
:impl automaton-core.log.tracking.be-error-tracking/add-context}
::log-registry/error-tracking-context {:description "For monitoring exceptions in the application"
:impl automaton-core.log.tracking.be-error-tracking/add-context}
::log-registry/error-tracking-alert {:description "For alerting about monitoring exceptions in the application"
:impl automaton-core.log.tracking.be-error-tracking/error-alert}})
2 changes: 1 addition & 1 deletion src/clj/automaton_core/log/tracking/be_error_tracking.clj
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

(defn- sentry-data
[ns level & message]
(let [context (if (map? (first message)) (merge (first message) {:ns ns}) {:ns ns})
(let [context (if (map? (first message)) (merge (first message) (when ns {:ns ns})) (when ns {:ns ns}))
message (if (map? (first message)) (rest message) message)]
{:message message
:level level
Expand Down
9 changes: 7 additions & 2 deletions src/cljc/automaton_core/utils/map.cljc
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,12 @@
(defn map-util-hashmappify-vals
"Converts an ordinary Clojure map into a Clojure map with nested map
values recursively translated into what modify-type-fn is returning. Based
on walk/stringify-keys."
on walk/stringify-keys.
When key or value is nil, the pair is removed, as the hashmap doesn't allow null keys/values."
[m modify-type-fn]
(let [f (fn [[k v]] (let [k (if (keyword? k) (name k) k) v (if (keyword? v) (name v) v)] (if (map? v) [k (modify-type-fn v)] [k v])))]
(let [f (fn [[k v]]
(let [k (if (keyword? k) (str (symbol k)) k)
v (if (keyword? v) (str (symbol v)) v)]
(cond (map? v) [k (modify-type-fn v)]
(and (some? v) (some? k)) [k v])))]
(walk/postwalk (fn [x] (if (map? x) (into {} (map f x)) x)) m)))

0 comments on commit 5853e7d

Please sign in to comment.