From 6ab9c4ac59a69da7375a14b5ea27b272f7a050b9 Mon Sep 17 00:00:00 2001 From: Peter Taoussanis Date: Tue, 26 May 2015 14:20:39 +0700 Subject: [PATCH] Attempted auto workaround for CLJ-124 --- README.md | 8 -------- src/taoensso/timbre.cljx | 7 +++++++ 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index a5cc4c0..c5a3ca6 100644 --- a/README.md +++ b/README.md @@ -76,14 +76,6 @@ java.lang.Exception: Oh noes <...> ``` -### Timbre slowing down your Clojure app shutdown? - -This is due to an outstanding [issue](http://dev.clojure.org/jira/browse/CLJ-124) in Clojure. As a workaround, add the following to your application's startup routine: - -```clojure -(.addShutdownHook (Runtime/getRuntime) (Thread. (fn [] (shutdown-agents)))) -``` - ### Configuration This is the biggest win over Java logging IMO. Here's `timbre/example-config` (also Timbre's default config): diff --git a/src/taoensso/timbre.cljx b/src/taoensso/timbre.cljx index dda9f6d..46fe859 100644 --- a/src/taoensso/timbre.cljx +++ b/src/taoensso/timbre.cljx @@ -555,3 +555,10 @@ [probability & body] `(do (assert (<= 0 ~probability 1) "Probability: 0 <= p <= 1") (when (< (rand) ~probability) ~@body))) + +;;;; Shutdown hook ; Workaround for http://dev.clojure.org/jira/browse/CLJ-124 + +#+clj +(defonce ^:private shutdown-hook + (.addShutdownHook (Runtime/getRuntime) + (Thread. (fn [] (shutdown-agents)))))