diff --git a/projects/main/src/taoensso/telemere/timbre.cljc b/projects/main/src/taoensso/telemere/timbre.cljc index 1de9df4..a53130d 100644 --- a/projects/main/src/taoensso/telemere/timbre.cljc +++ b/projects/main/src/taoensso/telemere/timbre.cljc @@ -161,3 +161,27 @@ (defn shutdown-appenders! "Prefer `telemere/stop-handlers!`." [] (tel/stop-handlers!)) + +(defn timbre->telemere-appender + "Returns a simple Timbre appender that'll redirect logs to Telemere." + [] + {:enabled? true + :min-level nil + :fn + (fn [data] + (let [{:keys [instant level context ?err output_ + ?ns-str ?file ?line ?column]} data] + + (taoensso.telemere/signal! + {:kind :timbre + :level level + :inst (taoensso.encore/as-?inst instant) + :ctx+ context + + :ns ?ns-str + :file ?file + :line ?line + :column ?column + + :error ?err + :msg (force output_)})))}) diff --git a/wiki/5-Migrating.md b/wiki/5-Migrating.md index d03da96..e09895b 100644 --- a/wiki/5-Migrating.md +++ b/wiki/5-Migrating.md @@ -28,9 +28,21 @@ This may be easier than it sounds. Remember that signals are just plain Clojure/ Feel free to [ping me](https://github.com/taoensso/telemere/issues) for assistance, or ask on the [`#telemere` Slack channel](https://www.taoensso.com/telemere/slack). -### 2. Imports +### 2. Logging calls -Switch your Timbre namespace imports: +What about all the Timbre logging calls in your code? + +You've got two choices- + +#### 2a. Redirect Timbre output to Telemere + +Add [`taoensso.telemere.timbre/timbre->telemere-appender`](https://cljdoc.org/d/com.taoensso/telemere/CURRENT/api/taoensso.telemere.timbre#timbre->telemere-appender) as a Timbre appender. It'll redirect Timbre's output to Telemere. + +In this case you may want to disable all your other Timbre appenders, and all your Timbre filtering. + +#### 2b. Change your ns imports + +The [`taoensso.telemere.timbre`](https://cljdoc.org/d/com.taoensso/telemere/CURRENT/api/taoensso.telemere.timbre) namespace contains a shim of most of Timbre's API so you can switch your Timbre namespace imports: ```clojure (ns my-ns @@ -39,9 +51,9 @@ Switch your Timbre namespace imports: ) ``` -The [`taoensso.telemere.timbre`](https://cljdoc.org/d/com.taoensso/telemere/CURRENT/api/taoensso.telemere.timbre) namespace contains a shim of most of Timbre's API. +In this case your Timbre appenders and filtering will be ignored. -Feel free to keep using this shim API **as long as you like**, there's no need to rewrite any of your existing code unless you specifically want to use features that are only possible with Telemere's [signal creators](./1-Getting-started#create-signals), etc. +Feel free to keep using the shim API **as long as you like**, there's no need to rewrite any of your existing code unless you specifically want to use features that are only possible with Telemere's [signal creators](./1-Getting-started#create-signals), etc. ### 3. Config @@ -67,4 +79,4 @@ This is easy, see [here](./3-Config#toolslogging). # From Java logging -This is easy, see [here](./3-Config#java-logging). +This is easy, see [here](./3-Config#java-logging). \ No newline at end of file