Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Production fixes #5

Merged
merged 2 commits into from
Jan 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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)))
4 changes: 2 additions & 2 deletions version.edn
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
;;Last generated version, note a failed push consume a number
{:major-version "0.0.-1"
:minor-version 25
:version "0.0.25"}
:minor-version 26
:version "0.0.26"}