         (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.

  *test-logs*
  nil)

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

   :message   (get log-entry 3)})

(defn logs-matching
  "Given a regular expression pattern, a sequence of log messages (in the format
  used by `clojure.tools.logging`, and (optionally) a log level (as a keyword
  that corresponds to those in `clojure.tools.logging`) return only the logs
  whose message matches the specified regular expression pattern that were
  logged at the given level (or at any level if not specified). (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] (logs-matching pattern logs nil))
  ([pattern logs level]
   {:pre  [(instance? java.util.regex.Pattern pattern)
           (coll? logs)
           (contains? legal-levels level)]}
   ;; the logs are formatted as sequences, where the keyword at index 1
   ;; contains the level and the string at index 3 contains the actual
   ;; log message.
   (let [matches-level? (fn [log-entry] (or (nil? level) (= level (get log-entry 1))))
         matches-msg? (fn [log-entry] (re-find pattern (get log-entry 3)))
         matches (filter #(and (matches-level? %) (matches-msg? %)) logs)]
     (map log-entry->map matches))))

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