-
Notifications
You must be signed in to change notification settings - Fork 146
Expand file tree
/
Copy pathlogging.clj
More file actions
23 lines (21 loc) · 779 Bytes
/
logging.clj
File metadata and controls
23 lines (21 loc) · 779 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
(ns ^:no-doc compojure.api.impl.logging
"Internal Compojure-api logging utility"
(:require [clojure.string :as str]))
;; Cursive-users
(declare log!)
;; use c.t.l logging if available, default to console logging
(try
(eval
`(do
(require 'clojure.tools.logging)
(defmacro ~'log! [& ~'args]
`(clojure.tools.logging/log ~@~'args))))
(catch Exception _
(let [log (fn [level more] (println (.toUpperCase (name level)) (str/join " " more)))]
(defn log! [level x & more]
(if (instance? Throwable x)
(do
(log level more)
(.printStackTrace ^Throwable x))
(log level (into [x] more))))
(log! :warn "clojure.tools.logging not found on classpath, compojure.api logging to console."))))