Skip to content

Commit

Permalink
Merge pull request #3 from kepler16/jv/change-xuvwwommnokk
Browse files Browse the repository at this point in the history
Replace timbre with System.Logger
  • Loading branch information
julienvincent authored Feb 23, 2024
2 parents b8fe6a5 + 844bf27 commit 54b0db8
Show file tree
Hide file tree
Showing 8 changed files with 36 additions and 19 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 ^Throwable 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)))
7 changes: 0 additions & 7 deletions packages/mallard/test/k16/mallard/executor_test.clj
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,10 @@
[k16.mallard.executor :as executor]
[k16.mallard.stores.memory :as stores.memory]
[matcher-combinators.test]
[taoensso.timbre :as log]
[tick.core :as t])
(:import
[clojure.lang ExceptionInfo]))

(defn- disable-logs [test]
(log/set-config! {})
(test))

(use-fixtures :once disable-logs)

(def migrations
[{:id "1"
:run-up! (fn [_])
Expand Down
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
3 changes: 1 addition & 2 deletions packages/mongo/test/k16/mallard/stores/mongo_test.clj
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@
[k16.mallard.test.mongo :as test.mongo]
[matcher-combinators.test]
[promesa.core :as p]
[tick.core :as t]
[taoensso.timbre]))
[tick.core :as t]))

(def ^:dynamic *mongo* nil)

Expand Down

0 comments on commit 54b0db8

Please sign in to comment.