Skip to content

Commit 39fe535

Browse files
committed
style: document functions
1 parent a1941b3 commit 39fe535

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

src/com/moclojer/components/core.clj

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@
1717
([filepath input-map]
1818
(config/map->Config {:config (config/read-config filepath input-map)})))
1919

20+
(def setup-logger logs/setup)
21+
2022
(defn new-database []
2123
(database/map->Database {}))
2224

src/com/moclojer/components/logs.clj

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@
77
(:import [clojure.core.async.impl.channels ManyToManyChannel]))
88

99
(defn ->str-values
10+
"Adapts all values (including nested maps' values) from given
11+
map `m` to a string.
12+
13+
This is because OpenSearch only accepts string json values."
1014
[m]
1115
(reduce-kv
1216
(fn [acc k v]
@@ -17,6 +21,7 @@
1721
{} m))
1822

1923
(defn signal->opensearch-log
24+
"Adapts a telemere signal to a pre-defined schema for OpenSearch."
2025
[{:keys [thread location] :as signal}]
2126
(-> (select-keys signal [:level :ctx :data :msg_ :error :uid :inst])
2227
(merge {"thread/group" (:group thread)
@@ -45,7 +50,11 @@
4550

4651
(defonce log-ch (atom nil))
4752

48-
(defn setup [config level env & [index]]
53+
(defn setup
54+
"If on dev `env`, does basically nothing besides setting the min
55+
level. On `prod` env however, an async channel waits for log events,
56+
which are then sent to OpenSearch."
57+
[config level env & [index]]
4958
(let [prod? (= env :prod)
5059
log-ch' (swap!
5160
log-ch

0 commit comments

Comments
 (0)