         (is (logged? #\"^hi$\" :info)))"
   (let [pattern       (nth form 1)
         level         (nth form 2 nil)
-        legal-levels  #{nil :trace :debug :info :warn :error :fatal}
         debug-msg     "; `with-test-logging-debug` may be useful for debugging tests."]
     (when-not (instance? Pattern pattern)
       (throw (IllegalArgumentException.

   :message   (get log-entry 3)})

(defn logs-matching
  "Given a regular expression pattern and a sequence of log messages (in the format
  used by `clojure.tools.logging`, return only the logs whose message matches the
  specified regular expression pattern.  (Intended to be used alongside
  `with-log-output` for tests that are validating log output.)  The result is
  a sequence of maps, each of which contains the following keys:
  `:namespace`, `:level`, `:exception`, and `:message`."
  [pattern logs]
  {:pre  [(instance? java.util.regex.Pattern pattern)
          (coll? logs)]}
  ;; the logs are formatted as sequences, where the string at index 3 contains
  ;; the actual log message.
  (let [matches (filter #(re-find pattern (get % 3)) logs)]
    (map log-entry->map matches)))

(defn log-to-console
  "Utility function called by atom-logger and atom-appender to log entries to the

  *test-logs*
  nil)

(def legal-levels #{nil :trace :debug :info :warn :error :fatal})

(defn- log-entry->map
  [log-entry]
  {:namespace (get log-entry 0)
