Liking cljdoc? Tell your friends :D

clojure.tools.logging

Logging macros which delegate to a specific logging implementation. At runtime a specific implementation is selected by invoking clojure.tools.logging.impl/find-factory.

The logging implementation can be explicitly provided by using binding or alter-var-root to change the value of logger-factory to another implementation of clojure.tools.logging.impl/LoggerFactory (see also the *-factory functions in the impl namespace).

Logging macros which delegate to a specific logging implementation. At
runtime a specific implementation is selected by invoking
clojure.tools.logging.impl/find-factory.

The logging implementation can be explicitly provided by using
binding or alter-var-root to change the value of *logger-factory* to
another implementation of clojure.tools.logging.impl/LoggerFactory
(see also the *-factory functions in the impl namespace).
raw docstring

clojure.tools.logging.impl

Protocols used to allow access to logging implementations. This namespace only need be used by those providing logging implementations to be consumed by the core api.

Protocols used to allow access to logging implementations.
This namespace only need be used by those providing logging
implementations to be consumed by the core api.
raw docstring

clojure.tools.logging.test

Extensible support for testing whether logging calls are made.

Usage example: (with-log (log/info "Hello World!") (log/error (Exception. "Did a thing") "Error: oops") (prn (logged? ns :info #"Hello")) ; true (prn (logged? ns :error [Throwable #"thing"] #"Error:")) ; true (prn (logged? ns :debug "Hi"))) ; false

Extension example, testing custom message types: (defrecord ContextualMessage [text context])

(defmethod match-message? [[String Map] ContextualMessage] [[expected-text expected-context] actual] (and (= expected-text (:text actual)) (= expected-context (-> actual :context (select-keys (keys expected-context))))))

(with-log (log/log :debug (->ContextualMessage "stuff" {:a 1 :b 2})) (prn (logged? ns :debug ["stuff" {:a 1}])) ; true (prn (logged? ns :debug ["stuff" {:a 1 :b 2}])) ; true (prn (logged? ns :debug ["stuff" {:a 1 :c 3}]))) ; false

Extensible support for testing whether logging calls are made.

Usage example:
  (with-log
    (log/info "Hello World!")
    (log/error (Exception. "Did a thing") "Error: oops")
    (prn (logged? *ns* :info #"Hello"))                                ; true
    (prn (logged? *ns* :error [Throwable #"thing"] #"Error:"))       ; true
    (prn (logged? *ns* :debug "Hi")))                                  ; false


Extension example, testing custom message types:
  (defrecord ContextualMessage [text context])

  (defmethod match-message? [[String Map] ContextualMessage]
    [[expected-text expected-context] actual]
    (and (= expected-text (:text actual))
         (= expected-context (-> actual :context (select-keys (keys expected-context))))))

  (with-log
    (log/log :debug (->ContextualMessage "stuff" {:a 1 :b 2}))
    (prn (logged? *ns* :debug ["stuff" {:a 1}]))                   ; true
    (prn (logged? *ns* :debug ["stuff" {:a 1 :b 2}]))              ; true
    (prn (logged? *ns* :debug ["stuff" {:a 1 :c 3}])))             ; false
raw docstring

cljdoc is a website building & hosting documentation for Clojure/Script libraries

× close