       (is (== 6 @cnt)))))
 
 (deftest log-msg
-  (with-test-logging [#{:debug} log-entry]
+  (with-log
     (log :debug "foo")
-    (is (= ["clojure.tools.test-logging"
-            :debug
-            nil
-            "foo"]
-           @log-entry))))
+    (is (logged? "clojure.tools.test-logging"
+                 :debug
+                 nil
+                 "foo"))))
 
 (deftest log-ex
-  (with-test-logging [#{:debug} log-entry]
+  (with-log
     (let [e (Exception.)]
       (log :debug e "foo")
-      (is (= ["clojure.tools.test-logging"
-              :debug
-              e
-              "foo"]
-             @log-entry)))))
+      (is (logged? "clojure.tools.test-logging"
+                   :debug
+                   e
+                   "foo")))))
 
 (deftest log-custom-ns
-  (with-test-logging [#{:debug} log-entry]
+  (with-log
     (let [e (Exception.)]
       (log "other.ns" :debug e "foo")
-      (is (= ["other.ns"
-              :debug
-              e
-              "foo"]
-             @log-entry)))))
+      (is (logged? "other.ns"
+                   :debug
+                   e
+                   "foo")))))
 
 (def all-levels #{:trace :debug :info :warn :error :fatal})
 (def default-tx-agent-levels #{:info :warn})

        clojure.tools.logging)
  (:require
    [clojure.set :as set]
    [clojure.tools.logging.impl :as impl]))

(defn test-factory [enabled-set entries-atom agent-used-atom]
  (let [main-thread (Thread/currentThread)]
    (reify impl/LoggerFactory
      (name [_] "test factory")
      (get-logger [_ log-ns]
        (reify impl/Logger
          (enabled? [_ level] (contains? enabled-set level))
          (write! [_ lvl ex msg]
            (reset! entries-atom [(str log-ns) lvl ex msg])
            (reset! agent-used-atom (not (identical? main-thread (Thread/currentThread))))))))))

(defmacro with-test-logging
  [[enabled-level-set log-entry-sym agent-used?-sym] & body]
  (let [enabled-level-set (or enabled-level-set #{:trace :debug :info :warn :error :fatal})
        log-entry-sym (or log-entry-sym 'log-entry-sym)
        agent-used?-sym (or agent-used?-sym 'agent-used?-sym)]
    `(let [~log-entry-sym (atom nil)
           ~agent-used?-sym (atom nil)]
       (binding [*logger-factory* (test-factory
                                    ~enabled-level-set
                                    ~log-entry-sym
                                    ~agent-used?-sym)]
         ~@body))))

(deftest log-yields-nil
  (let [enabled-logger  (reify impl/Logger


(deftest println-style-ex
  (let [e (Exception.)]
    (are [f kw] (with-log
                  (f e "hello" "world")
                  (logged? "clojure.tools.test-logging" kw e "hello world"))
      trace :trace
      debug :debug
      info :info
