Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Fix TLOG-3: Moved implementation stuff to sub-namespaces.

  • Loading branch information...
commit 42dfba84a373e52a4e80af6467e47761e6f20678 1 parent 32b7077
Alexander Taggart authored
View
227 src/main/clojure/clojure/tools/logging.clj
@@ -17,29 +17,13 @@
clojure.tools.logging
[:use
[clojure.string :only [trim-newline]]
- [clojure.pprint :only [code-dispatch pprint with-pprint-dispatch]]])
-
-(defprotocol Logger
- "The protocol through which macros will interact with an underlying logging
- implementation. Implementations should at least support the six specified
- logging levels if they wish to benefit from the level-specific macros."
- (impl-enabled? [logger level]
- "Implementation-specific check if a particular level is enabled. End-users
- should not need to call this.")
- (impl-write! [logger level throwable message]
- "Implementation-specific write of a log message. End-users should not need
- to call this."))
-
-(defprotocol LoggerFactory
- "The protocol through which macros will obtain an instance satisfying Logger as
- well as providing information about the particular implementation being used.
- Implementations should be bound to *logger-factory* in order to be picked up by
- this library."
- (impl-name [factory]
- "Returns some text identifying the underlying implementation.")
- (impl-get-logger [factory logger-ns]
- "Returns an implementation-specific Logger by namespace. End-users should not
- need to call this."))
+ [clojure.pprint :only [code-dispatch pprint with-pprint-dispatch]]]
+ [:require [clojure.tools.logging
+ [commons-logging :as cl]
+ [impl :as impl]
+ [java-util-logging :as jul]
+ [log4j :as log4j]
+ [slf4j :as slf4j]]])
(def ^{:doc
"The default agent used for performing logging when direct logging is
@@ -76,10 +60,10 @@
(= *force* :agent) true
(= *force* :direct) false)
(send-off *logging-agent*
- (fn [_#] (impl-write! logger level throwable message)))
- (impl-write! logger level throwable message)))
+ (fn [_#] (impl/write! logger level throwable message)))
+ (impl/write! logger level throwable message)))
-(declare ^{:dynamic true} *logger-factory*) ; default LoggerFactory instance for calling impl-get-logger
+(declare ^{:dynamic true} *logger-factory*) ; default LoggerFactory instance for calling impl/get-logger
(defmacro log
"Evaluates and logs a message only if the specified level is enabled. See log*
@@ -91,8 +75,8 @@
([logger-ns level throwable message]
`(log *logger-factory* ~logger-ns ~level ~throwable ~message))
([logger-factory logger-ns level throwable message]
- `(let [logger# (impl-get-logger ~logger-factory ~logger-ns)]
- (if (impl-enabled? logger# ~level)
+ `(let [logger# (impl/get-logger ~logger-factory ~logger-ns)]
+ (if (impl/enabled? logger# ~level)
(log* logger# ~level ~throwable ~message)))))
(defmacro logp
@@ -102,8 +86,8 @@
[level x & more]
(if (or (instance? String x) (nil? more)) ; optimize for common case
`(log ~level (print-str ~x ~@more))
- `(let [logger# (impl-get-logger *logger-factory* ~*ns*)]
- (if (impl-enabled? logger# ~level)
+ `(let [logger# (impl/get-logger *logger-factory* ~*ns*)]
+ (if (impl/enabled? logger# ~level)
(if (instance? Throwable ~x) ; type check only when enabled
(log* logger# ~level ~x (print-str ~@more))
(log* logger# ~level nil (print-str ~x ~@more)))))))
@@ -115,20 +99,20 @@
[level x & more]
(if (or (instance? String x) (nil? more)) ; optimize for common case
`(log ~level (format ~x ~@more))
- `(let [logger# (impl-get-logger *logger-factory* ~*ns*)]
- (if (impl-enabled? logger# ~level)
+ `(let [logger# (impl/get-logger *logger-factory* ~*ns*)]
+ (if (impl/enabled? logger# ~level)
(if (instance? Throwable ~x) ; type check only when enabled
(log* logger# ~level ~x (format ~@more))
(log* logger# ~level nil (format ~x ~@more)))))))
(defmacro enabled?
- "Returns true if the specific logging level is enabled. Use of this function
+ "Returns true if the specific logging level is enabled. Use of this macro
should only be necessary if one needs to execute alternate code paths beyond
whether the log should be written to."
([level]
`(enabled? ~level ~*ns*))
([level logger-ns]
- `(impl-enabled? (impl-get-logger *logger-factory* ~logger-ns) ~level)))
+ `(impl/enabled? (impl/get-logger *logger-factory* ~logger-ns) ~level)))
(defmacro spy
"Evaluates expr and may write the form and its result to the log. Returns the
@@ -149,7 +133,7 @@
(defn log-stream
"Creates a PrintStream that will output to the log at the specified level."
[level logger-ns]
- (let [logger (impl-get-logger *logger-factory* logger-ns)]
+ (let [logger (impl/get-logger *logger-factory* logger-ns)]
(java.io.PrintStream.
(proxy [java.io.ByteArrayOutputStream] []
(flush []
@@ -288,167 +272,20 @@
[& args]
`(logf :fatal ~@args))
-
-;; Implementations of Logger and LoggerFactory protocols:
-
-(defn commons-logging
- "Returns a commons-logging-based implementation of the LoggerFactory protocol, or
- nil if not available. End-users should not need to call this."
- []
- (try
- (Class/forName "org.apache.commons.logging.Log")
- (eval
- '(do
- (extend-type org.apache.commons.logging.Log
- Logger
- (impl-enabled? [logger# level#]
- (condp = level#
- :trace (.isTraceEnabled logger#)
- :debug (.isDebugEnabled logger#)
- :info (.isInfoEnabled logger#)
- :warn (.isWarnEnabled logger#)
- :error (.isErrorEnabled logger#)
- :fatal (.isFatalEnabled logger#)
- (throw (IllegalArgumentException. (str level#)))))
- (impl-write! [logger# level# e# msg#]
- (condp = level#
- :trace (.trace logger# msg# e#)
- :debug (.debug logger# msg# e#)
- :info (.info logger# msg# e#)
- :warn (.warn logger# msg# e#)
- :error (.error logger# msg# e#)
- :fatal (.fatal logger# msg# e#)
- (throw (IllegalArgumentException. (str level#))))))
- (reify LoggerFactory
- (impl-name [_#]
- "org.apache.commons.logging")
- (impl-get-logger [_# logger-ns#]
- (org.apache.commons.logging.LogFactory/getLog (str logger-ns#))))))
- (catch Exception e nil)))
-
-(defn slf4j-logging
- "Returns a SLF4J-based implementation of the LoggerFactory protocol, or nil if
- not available. End-users should not need to call this."
- []
- (try
- (Class/forName "org.slf4j.Logger")
- (eval
- '(do
- (extend-type org.slf4j.Logger
- Logger
- (impl-enabled? [logger# level#]
- (condp = level#
- :trace (.isTraceEnabled logger#)
- :debug (.isDebugEnabled logger#)
- :info (.isInfoEnabled logger#)
- :warn (.isWarnEnabled logger#)
- :error (.isErrorEnabled logger#)
- :fatal (.isErrorEnabled logger#)
- (throw (IllegalArgumentException. (str level#)))))
- (impl-write! [^org.slf4j.Logger logger# level# ^Throwable e# msg#]
- (let [^String msg# (str msg#)]
- (condp = level#
- :trace (.trace logger# msg# e#)
- :debug (.debug logger# msg# e#)
- :info (.info logger# msg# e#)
- :warn (.warn logger# msg# e#)
- :error (.error logger# msg# e#)
- :fatal (.error logger# msg# e#)
- (throw (IllegalArgumentException. (str level#)))))))
- (reify LoggerFactory
- (impl-name [_#]
- "org.slf4j")
- (impl-get-logger [_# logger-ns#]
- (org.slf4j.LoggerFactory/getLogger ^String (str logger-ns#))))))
- (catch Exception e nil)))
-
-(defn log4j-logging
- "Returns a log4j-based implementation of the LoggerFactory protocol, or nil if
- not available. End-users should not need to call this."
- []
- (try
- (Class/forName "org.apache.log4j.Logger")
- (eval
- '(let [levels# {:trace org.apache.log4j.Level/TRACE
- :debug org.apache.log4j.Level/DEBUG
- :info org.apache.log4j.Level/INFO
- :warn org.apache.log4j.Level/WARN
- :error org.apache.log4j.Level/ERROR
- :fatal org.apache.log4j.Level/FATAL}]
- (extend-type org.apache.log4j.Logger
- Logger
- (impl-enabled? [logger# level#]
- (.isEnabledFor logger#
- (or
- (levels# level#)
- (throw (IllegalArgumentException. (str level#))))))
- (impl-write! [logger# level# e# msg#]
- (let [level# (or
- (levels# level#)
- (throw (IllegalArgumentException. (str level#))))]
- (if-not e#
- (.log logger# level# msg#)
- (.log logger# level# msg# e#)))))
- (reify LoggerFactory
- (impl-name [_#]
- "org.apache.log4j")
- (impl-get-logger [_# logger-ns#]
- (org.apache.log4j.Logger/getLogger ^String (str logger-ns#))))))
- (catch Exception e nil)))
-
-(defn java-util-logging
- "Returns a java.util.logging-based implementation of the LoggerFactory protocol,
- or nil if not available. End-users should not need to call this."
- []
- (try
- (Class/forName "java.util.logging.Logger")
- (eval
- '(let [levels# {:trace java.util.logging.Level/FINEST
- :debug java.util.logging.Level/FINE
- :info java.util.logging.Level/INFO
- :warn java.util.logging.Level/WARNING
- :error java.util.logging.Level/SEVERE
- :fatal java.util.logging.Level/SEVERE}]
- (extend-type java.util.logging.Logger
- Logger
- (impl-enabled? [logger# level#]
- (.isLoggable logger#
- (or
- (levels# level#)
- (throw (IllegalArgumentException. (str level#))))))
- (impl-write! [logger# level# ^Throwable e# msg#]
- (let [^java.util.logging.Level level#
- (or
- (levels# level#)
- (throw (IllegalArgumentException. (str level#))))
- ^String msg# (str msg#)]
- (if e#
- (.log logger# level# msg# e#)
- (.log logger# level# msg#)))))
- (reify LoggerFactory
- (impl-name [_#]
- "java.util.logging")
- (impl-get-logger [_# logger-ns#]
- (java.util.logging.Logger/getLogger (str logger-ns#))))))
- (catch Exception e nil)))
-
-(defn find-factory
- "Returns the first LoggerFactory found that is available from commons-logging,
- slf4j-logging, log4j-logging, or java-util-logging. End-users should not need
- to call this."
- []
- (or (commons-logging)
- (slf4j-logging)
- (log4j-logging)
- (java-util-logging)
- (throw ; this should never happen in 1.5+
- (RuntimeException.
- "Valid logging implementation could not be found."))))
+(defn- find-factory []
+ (or (cl/load-factory)
+ (slf4j/load-factory)
+ (log4j/load-factory)
+ (jul/load-factory)
+ (throw ; this should never happen in 1.5+
+ (RuntimeException.
+ "Valid logging implementation could not be found."))))
(def ^{:doc
- "An instance satisfying the LoggerFactory protocol. Used internally when needing
- to obtain an instance satisfying the Logger protocol. Defaults to the value
- returned from find-factory. Can be rebound to provide alternate logging
- implementations" :dynamic true}
+ "An instance satisfying the LoggerFactory protocol. Used internally when
+ needing to obtain an instance satisfying the Logger protocol. Defaults to the
+ first LoggerFactory found that is available from commons-logging,
+ slf4j-logging, log4j-logging, or java-util-logging. Can be rebound to provide
+ alternate logging implementations" :dynamic true}
*logger-factory*
(find-factory))
View
45 src/main/clojure/clojure/tools/logging/commons_logging.clj
@@ -0,0 +1,45 @@
+;; Copyright (c) Alex Taggart. All rights reserved. The use
+;; and distribution terms for this software are covered by the Eclipse
+;; Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php)
+;; which can be found in the file epl-v10.html at the root of this
+;; distribution. By using this software in any fashion, you are
+;; agreeing to be bound by the terms of this license. You must not
+;; remove this notice, or any other, from this software.
+
+(ns clojure.tools.logging.commons-logging
+ (:require [clojure.tools.logging.impl :as impl]))
+
+(defn load-factory
+ "Returns a commons-logging-based implementation of the LoggerFactory protocol, or
+ nil if not available. End-users should not need to call this."
+ []
+ (try
+ (Class/forName "org.apache.commons.logging.Log")
+ (eval
+ '(do
+ (extend-type org.apache.commons.logging.Log
+ impl/Logger
+ (enabled? [logger# level#]
+ (condp = level#
+ :trace (.isTraceEnabled logger#)
+ :debug (.isDebugEnabled logger#)
+ :info (.isInfoEnabled logger#)
+ :warn (.isWarnEnabled logger#)
+ :error (.isErrorEnabled logger#)
+ :fatal (.isFatalEnabled logger#)
+ (throw (IllegalArgumentException. (str level#)))))
+ (write! [logger# level# e# msg#]
+ (condp = level#
+ :trace (.trace logger# msg# e#)
+ :debug (.debug logger# msg# e#)
+ :info (.info logger# msg# e#)
+ :warn (.warn logger# msg# e#)
+ :error (.error logger# msg# e#)
+ :fatal (.fatal logger# msg# e#)
+ (throw (IllegalArgumentException. (str level#))))))
+ (reify impl/LoggerFactory
+ (name [_#]
+ "org.apache.commons.logging")
+ (get-logger [_# logger-ns#]
+ (org.apache.commons.logging.LogFactory/getLog (str logger-ns#))))))
+ (catch Exception e nil)))
View
32 src/main/clojure/clojure/tools/logging/impl.clj
@@ -0,0 +1,32 @@
+;; Copyright (c) Alex Taggart. All rights reserved. The use
+;; and distribution terms for this software are covered by the Eclipse
+;; Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php)
+;; which can be found in the file epl-v10.html at the root of this
+;; distribution. By using this software in any fashion, you are
+;; agreeing to be bound by the terms of this license. You must not
+;; remove this notice, or any other, from this software.
+
+(ns ^{:author "Alex Taggart"
+ :doc "Protocols used to allow access to logging implementations.
+ End-users should not need to use this namespace."}
+ clojure.tools.logging.impl
+ (:refer-clojure :exclude [name]))
+
+(defprotocol Logger
+ "The protocol through which macros will interact with an underlying logging
+ implementation. Implementations should at least support the six standard
+ logging levels if they wish to work from the level-specific macros."
+ (enabled? [logger level]
+ "Check if a particular level is enabled for the given Logger.")
+ (write! [logger level throwable message]
+ "Writes a log message to the given Logger."))
+
+(defprotocol LoggerFactory
+ "The protocol through which macros will obtain an instance satisfying Logger as
+ well as providing information about the particular implementation being used.
+ Implementations should be bound to *logger-factory* in order to be picked up by
+ this library."
+ (name [factory]
+ "Returns some text identifying the underlying implementation.")
+ (get-logger [factory logger-ns]
+ "Returns an implementation-specific Logger by namespace."))
View
47 src/main/clojure/clojure/tools/logging/java_util_logging.clj
@@ -0,0 +1,47 @@
+;; Copyright (c) Alex Taggart. All rights reserved. The use
+;; and distribution terms for this software are covered by the Eclipse
+;; Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php)
+;; which can be found in the file epl-v10.html at the root of this
+;; distribution. By using this software in any fashion, you are
+;; agreeing to be bound by the terms of this license. You must not
+;; remove this notice, or any other, from this software.
+
+(ns clojure.tools.logging.java-util-logging
+ (:require [clojure.tools.logging.impl :as impl]))
+
+(defn load-factory
+ "Returns a java.util.logging-based implementation of the LoggerFactory protocol,
+ or nil if not available. End-users should not need to call this."
+ []
+ (try
+ (Class/forName "java.util.logging.Logger")
+ (eval
+ '(let [levels# {:trace java.util.logging.Level/FINEST
+ :debug java.util.logging.Level/FINE
+ :info java.util.logging.Level/INFO
+ :warn java.util.logging.Level/WARNING
+ :error java.util.logging.Level/SEVERE
+ :fatal java.util.logging.Level/SEVERE}]
+ (extend-type java.util.logging.Logger
+ impl/Logger
+ (enabled? [logger# level#]
+ (.isLoggable logger#
+ (or
+ (levels# level#)
+ (throw (IllegalArgumentException. (str level#))))))
+ (write! [logger# level# ^Throwable e# msg#]
+ (let [^java.util.logging.Level level#
+ (or
+ (levels# level#)
+ (throw (IllegalArgumentException. (str level#))))
+ ^String msg# (str msg#)]
+ (if e#
+ (.log logger# level# msg# e#)
+ (.log logger# level# msg#)))))
+ (reify impl/LoggerFactory
+ (name [_#]
+ "java.util.logging")
+ (get-logger [_# logger-ns#]
+ (java.util.logging.Logger/getLogger (str logger-ns#))))))
+ (catch Exception e nil)))
+
View
45 src/main/clojure/clojure/tools/logging/log4j.clj
@@ -0,0 +1,45 @@
+;; Copyright (c) Alex Taggart. All rights reserved. The use
+;; and distribution terms for this software are covered by the Eclipse
+;; Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php)
+;; which can be found in the file epl-v10.html at the root of this
+;; distribution. By using this software in any fashion, you are
+;; agreeing to be bound by the terms of this license. You must not
+;; remove this notice, or any other, from this software.
+
+(ns clojure.tools.logging.log4j
+ (:require [clojure.tools.logging.impl :as impl]))
+
+(defn load-factory
+ "Returns a log4j-based implementation of the LoggerFactory protocol, or nil if
+ not available. End-users should not need to call this."
+ []
+ (try
+ (Class/forName "org.apache.log4j.Logger")
+ (eval
+ '(let [levels# {:trace org.apache.log4j.Level/TRACE
+ :debug org.apache.log4j.Level/DEBUG
+ :info org.apache.log4j.Level/INFO
+ :warn org.apache.log4j.Level/WARN
+ :error org.apache.log4j.Level/ERROR
+ :fatal org.apache.log4j.Level/FATAL}]
+ (extend-type org.apache.log4j.Logger
+ impl/Logger
+ (enabled? [logger# level#]
+ (.isEnabledFor logger#
+ (or
+ (levels# level#)
+ (throw (IllegalArgumentException. (str level#))))))
+ (write! [logger# level# e# msg#]
+ (let [level# (or
+ (levels# level#)
+ (throw (IllegalArgumentException. (str level#))))]
+ (if-not e#
+ (.log logger# level# msg#)
+ (.log logger# level# msg# e#)))))
+ (reify impl/LoggerFactory
+ (name [_#]
+ "org.apache.log4j")
+ (get-logger [_# logger-ns#]
+ (org.apache.log4j.Logger/getLogger ^String (str logger-ns#))))))
+ (catch Exception e nil)))
+
View
47 src/main/clojure/clojure/tools/logging/slf4j.clj
@@ -0,0 +1,47 @@
+;; Copyright (c) Alex Taggart. All rights reserved. The use
+;; and distribution terms for this software are covered by the Eclipse
+;; Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php)
+;; which can be found in the file epl-v10.html at the root of this
+;; distribution. By using this software in any fashion, you are
+;; agreeing to be bound by the terms of this license. You must not
+;; remove this notice, or any other, from this software.
+
+(ns clojure.tools.logging.slf4j
+ (:require [clojure.tools.logging.impl :as impl]))
+
+(defn load-factory
+ "Returns a SLF4J-based implementation of the LoggerFactory protocol, or nil if
+ not available. End-users should not need to call this."
+ []
+ (try
+ (Class/forName "org.slf4j.Logger")
+ (eval
+ '(do
+ (extend-type org.slf4j.Logger
+ impl/Logger
+ (enabled? [logger# level#]
+ (condp = level#
+ :trace (.isTraceEnabled logger#)
+ :debug (.isDebugEnabled logger#)
+ :info (.isInfoEnabled logger#)
+ :warn (.isWarnEnabled logger#)
+ :error (.isErrorEnabled logger#)
+ :fatal (.isErrorEnabled logger#)
+ (throw (IllegalArgumentException. (str level#)))))
+ (write! [^org.slf4j.Logger logger# level# ^Throwable e# msg#]
+ (let [^String msg# (str msg#)]
+ (condp = level#
+ :trace (.trace logger# msg# e#)
+ :debug (.debug logger# msg# e#)
+ :info (.info logger# msg# e#)
+ :warn (.warn logger# msg# e#)
+ :error (.error logger# msg# e#)
+ :fatal (.error logger# msg# e#)
+ (throw (IllegalArgumentException. (str level#)))))))
+ (reify impl/LoggerFactory
+ (name [_#]
+ "org.slf4j")
+ (get-logger [_# logger-ns#]
+ (org.slf4j.LoggerFactory/getLogger ^String (str logger-ns#))))))
+ (catch Exception e nil)))
+
View
143 src/test/clojure/clojure/tools/test_logging.clj
@@ -1,21 +1,22 @@
(ns clojure.tools.test-logging
- [:use clojure.test]
- [:require [clojure.tools.logging :as logger]])
+ [:use clojure.test
+ clojure.tools.logging]
+ [:require [clojure.tools.logging.impl :as impl]])
(def ^{:dynamic true} *entries* (atom []))
(defn test-factory [enabled-set]
- (reify logger/LoggerFactory
- (impl-name [_] "test factory")
- (impl-get-logger [_ log-ns]
- (reify logger/Logger
- (impl-enabled? [_ level] (contains? enabled-set level))
- (impl-write! [_ lvl ex msg]
+ (reify impl/LoggerFactory
+ (name [_] "test factory")
+ (get-logger [_ log-ns]
+ (reify impl/Logger
+ (enabled? [_ level] (contains? enabled-set level))
+ (write! [_ lvl ex msg]
(swap! *entries* conj [(str log-ns) lvl ex msg]))))))
(use-fixtures :once
(fn [f]
- (binding [logger/*logger-factory*
+ (binding [*logger-factory*
(test-factory #{:trace :debug :info :warn :error :fatal})]
(f))))
@@ -26,7 +27,7 @@
(deftest log-msg
- (logger/log :debug "foo")
+ (log :debug "foo")
(is (= ["clojure.tools.test-logging"
:debug
nil
@@ -35,7 +36,7 @@
(deftest log-ex
(let [e (Exception.)]
- (logger/log :debug e "foo")
+ (log :debug e "foo")
(is (= ["clojure.tools.test-logging"
:debug
e
@@ -44,7 +45,7 @@
(deftest log-custom-ns
(let [e (Exception.)]
- (logger/log "other.ns" :debug e "foo")
+ (log "other.ns" :debug e "foo")
(is (= ["other.ns"
:debug
e
@@ -60,8 +61,8 @@
(compare-and-set! flag false true)
(apply so a f args))]
(dosync
- (logger/log :info "foo")))
- (await logger/*logging-agent*)
+ (log :info "foo")))
+ (await *logging-agent*)
(is (= ["clojure.tools.test-logging"
:info
nil
@@ -76,8 +77,8 @@
(compare-and-set! flag false true)
(apply so a f args))]
(dosync
- (logger/log :error "foo")))
- (await logger/*logging-agent*)
+ (log :error "foo")))
+ (await *logging-agent*)
(is (= ["clojure.tools.test-logging"
:error
nil
@@ -91,10 +92,10 @@
(binding [send-off (fn [a f & args]
(compare-and-set! flag false true)
(apply so a f args))
- logger/*tx-agent-levels* #{:error}]
+ *tx-agent-levels* #{:error}]
(dosync
- (logger/log :error "foo")))
- (await logger/*logging-agent*)
+ (log :error "foo")))
+ (await *logging-agent*)
(is (= ["clojure.tools.test-logging"
:error
nil
@@ -108,9 +109,9 @@
(binding [send-off (fn [a f & args]
(compare-and-set! flag false true)
(apply so a f args))
- logger/*force* :agent]
- (logger/log :debug "foo"))
- (await logger/*logging-agent*)
+ *force* :agent]
+ (log :debug "foo"))
+ (await *logging-agent*)
(is (= ["clojure.tools.test-logging"
:debug
nil
@@ -124,10 +125,10 @@
(binding [send-off (fn [a f & args]
(compare-and-set! flag false true)
(apply so a f args))
- logger/*force* :direct]
+ *force* :direct]
(dosync
- (logger/log :info "foo")))
- (await logger/*logging-agent*)
+ (log :info "foo")))
+ (await *logging-agent*)
(is (= ["clojure.tools.test-logging"
:info
nil
@@ -139,7 +140,7 @@
(deftest logp-msg-no-optimize
(let [a "foo"
b "bar"]
- (logger/logp :debug a b))
+ (logp :debug a b))
(is (= ["clojure.tools.test-logging"
:debug
nil
@@ -147,7 +148,7 @@
(peek @*entries*))))
(deftest logp-msg1
- (logger/logp :debug "hello")
+ (logp :debug "hello")
(is (= ["clojure.tools.test-logging"
:debug
nil
@@ -155,7 +156,7 @@
(peek @*entries*))))
(deftest logp-msg2
- (logger/logp :debug "hello" "world")
+ (logp :debug "hello" "world")
(is (= ["clojure.tools.test-logging"
:debug
nil
@@ -164,7 +165,7 @@
(deftest logp-ex0
(let [e (Exception.)]
- (logger/logp :debug e)
+ (logp :debug e)
(is (= ["clojure.tools.test-logging"
:debug
nil
@@ -173,7 +174,7 @@
(deftest logp-ex1
(let [e (Exception.)]
- (logger/logp :debug e "hello")
+ (logp :debug e "hello")
(is (= ["clojure.tools.test-logging"
:debug
e
@@ -182,7 +183,7 @@
(deftest logp-ex2
(let [e (Exception.)]
- (logger/logp :debug e "hello" "world")
+ (logp :debug e "hello" "world")
(is (= ["clojure.tools.test-logging"
:debug
e
@@ -192,7 +193,7 @@
(deftest logf-msg-no-optimize
(let [a "foo %s"
b "bar"]
- (logger/logf :debug a b))
+ (logf :debug a b))
(is (= ["clojure.tools.test-logging"
:debug
nil
@@ -200,7 +201,7 @@
(peek @*entries*))))
(deftest logf-msg1
- (logger/logf :debug "hello")
+ (logf :debug "hello")
(is (= ["clojure.tools.test-logging"
:debug
nil
@@ -208,7 +209,7 @@
(peek @*entries*))))
(deftest logf-msg3
- (logger/logf :debug "%s %s" "hello" "world")
+ (logf :debug "%s %s" "hello" "world")
(is (= ["clojure.tools.test-logging"
:debug
nil
@@ -216,11 +217,11 @@
(peek @*entries*))))
(deftest logf-ex0
- (is (thrown? Exception (logger/logf :debug (Exception.)))))
+ (is (thrown? Exception (logf :debug (Exception.)))))
(deftest logf-ex3
(let [e (Exception.)]
- (logger/logf :debug e "%s %s" "hello" "world")
+ (logf :debug e "%s %s" "hello" "world")
(is (= ["clojure.tools.test-logging"
:debug
e
@@ -228,14 +229,14 @@
(peek @*entries*)))))
(deftest enabled-true
- (is (= true (logger/enabled? :fatal))))
+ (is (= true (enabled? :fatal))))
(deftest enabled-false
- (binding [logger/*logger-factory* (test-factory #{})]
- (is (= false (logger/enabled? :fatal)))))
+ (binding [*logger-factory* (test-factory #{})]
+ (is (= false (enabled? :fatal)))))
(deftest spy-default
- (logger/spy (+ 4 5))
+ (spy (+ 4 5))
(is (= ["clojure.tools.test-logging"
:debug
nil
@@ -243,7 +244,7 @@
(peek @*entries*))))
(deftest spy-level
- (logger/spy :fatal (+ 4 5))
+ (spy :fatal (+ 4 5))
(is (= ["clojure.tools.test-logging"
:fatal
nil
@@ -252,7 +253,7 @@
(comment
(deftest capturing
- (logger/log-capture! "foobar")
+ (log-capture! "foobar")
(.println System/out "hello world")
(is (= ["foobar"
:info
@@ -265,10 +266,10 @@
nil
"oh noes"]
(peek @*entries*)))
- (logger/log-uncapture!))
+ (log-uncapture!))
(deftest capturing-level
- (logger/log-capture! "foobar" :error :fatal)
+ (log-capture! "foobar" :error :fatal)
(.println System/out "hello world")
(is (= ["foobar"
:error
@@ -281,10 +282,10 @@
nil
"oh noes"]
(peek @*entries*)))
- (logger/log-uncapture!))
+ (log-uncapture!))
(deftest with-logs-default
- (logger/with-logs "foobar" (println "hello world"))
+ (with-logs "foobar" (println "hello world"))
(is (= ["foobar"
:info
nil
@@ -292,7 +293,7 @@
(peek @*entries*))))
(deftest with-logs-level
- (logger/with-logs ["foobar" :fatal :fatal] (println "hello world"))
+ (with-logs ["foobar" :fatal :fatal] (println "hello world"))
(is (= ["foobar"
:fatal
nil
@@ -309,12 +310,12 @@
(do
(f "hello" "world")
(peek @*entries*)))
- logger/trace :trace
- logger/debug :debug
- logger/info :info
- logger/warn :warn
- logger/error :error
- logger/fatal :fatal))
+ trace :trace
+ debug :debug
+ info :info
+ warn :warn
+ error :error
+ fatal :fatal))
(deftest println-style-ex
(let [e (Exception.)]
@@ -326,12 +327,12 @@
(do
(f e "hello" "world")
(peek @*entries*)))
- logger/trace :trace
- logger/debug :debug
- logger/info :info
- logger/warn :warn
- logger/error :error
- logger/fatal :fatal)))
+ trace :trace
+ debug :debug
+ info :info
+ warn :warn
+ error :error
+ fatal :fatal)))
(deftest format-style
(are [f kw]
@@ -342,12 +343,12 @@
(do
(f "%s %s" "hello" "world")
(peek @*entries*)))
- logger/tracef :trace
- logger/debugf :debug
- logger/infof :info
- logger/warnf :warn
- logger/errorf :error
- logger/fatalf :fatal))
+ tracef :trace
+ debugf :debug
+ infof :info
+ warnf :warn
+ errorf :error
+ fatalf :fatal))
(deftest format-style-ex
(let [e (Exception.)]
@@ -359,9 +360,9 @@
(do
(f e "%s %s" "hello" "world")
(peek @*entries*)))
- logger/tracef :trace
- logger/debugf :debug
- logger/infof :info
- logger/warnf :warn
- logger/errorf :error
- logger/fatalf :fatal)))
+ tracef :trace
+ debugf :debug
+ infof :info
+ warnf :warn
+ errorf :error
+ fatalf :fatal)))
Please sign in to comment.
Something went wrong with that request. Please try again.