Skip to content

Commit

Permalink
minor: Replace timbre with System.Logger
Browse files Browse the repository at this point in the history
  • Loading branch information
julienvincent committed Feb 23, 2024
1 parent b8fe6a5 commit 61ed0f8
Show file tree
Hide file tree
Showing 6 changed files with 35 additions and 10 deletions.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -130,3 +130,7 @@ You can either explicitly require each migration and use the `ns` loader or you
"Preload migrations to ensure that the `require` statements are analysed during native-image compilation"
(loaders.fs/load-migrations! "migrations")) ;; where the folder `migrations` is on your classpath.
```

## Roadmap

+ Provide some way to run a migration on the migration state.
3 changes: 1 addition & 2 deletions packages/mallard/deps.edn
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@
:paths ["src"]

:deps {tick/tick {:mvn/version "0.7.5"}
metosin/malli {:mvn/version "0.13.0"}
com.taoensso/timbre {:mvn/version "6.2.2"}}
metosin/malli {:mvn/version "0.13.0"}}

:aliases {:build {:deps {local/build {:local/root "../../build"}}
:ns-default build}
Expand Down
8 changes: 4 additions & 4 deletions packages/mallard/src/k16/mallard/executor.clj
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
(ns k16.mallard.executor
(:require
[k16.mallard.datastore :as datastore.api]
[k16.mallard.log :as log]
[malli.core :as m]
[malli.error :as me]
[tick.core :as t]
[taoensso.timbre :as log]))
[tick.core :as t]))

(set! *warn-on-reflection* true)

Expand Down Expand Up @@ -146,8 +146,8 @@

(try
(if (pos? (count unapplied))
(log/info (str "Running " (count unapplied) " operations"))
(log/info "No operations to run"))
(log/info (str "Running " (count unapplied) " operations [" direction "]"))
(log/info "No unapplied operations to run"))

(doseq [{:keys [id operation]} unapplied]
(when (not operation)
Expand Down
24 changes: 24 additions & 0 deletions packages/mallard/src/k16/mallard/log.clj
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
(ns k16.mallard.log
(:import
[java.lang System System$Logger System$Logger$Level]))

(set! *warn-on-reflection* true)

(defn get-logger ^System$Logger [name]
(System/getLogger name))

(defmacro info [message]
`(let [logger# (get-logger (str ~*ns*))]
(.log logger# System$Logger$Level/INFO ~message)))

(defn -log-error
([^System$Logger logger ^String msg]
(.log logger System$Logger$Level/ERROR msg))
([^System$Logger logger ^String msg ^Object ex]
(.log logger System$Logger$Level/ERROR msg ex)))

(defmacro error
([message]
`(-log-error (get-logger (str ~*ns*)) ~message))
([message ex]
`(-log-error (get-logger (str ~*ns*)) ~message ~ex)))
4 changes: 1 addition & 3 deletions packages/mongo/deps.edn
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,7 @@

metosin/malli {:mvn/version "0.13.0"}
funcool/promesa {:mvn/version "11.0.678"}
tick/tick {:mvn/version "0.7.5"}

com.taoensso/timbre {:mvn/version "6.2.2"}}
tick/tick {:mvn/version "0.7.5"}}

:aliases {:build {:deps {local/build {:local/root "../../build"}}
:ns-default build}
Expand Down
2 changes: 1 addition & 1 deletion packages/mongo/src/k16/mallard/stores/mongo.clj
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
[mongo-driver-3.collection :as mongo]
[promesa.core :as p]
[promesa.exec :as exec]
[taoensso.timbre :as log]
[k16.mallard.log :as log]
[tick.core :as t])
(:import
[com.mongodb.client.result UpdateResult]))
Expand Down

0 comments on commit 61ed0f8

Please sign in to comment.