CrossClj

0.5.0-alpha docs

SourceDocs



RECENT

    tools.logging

    Clojars


    OWNER
    Clojure
    clojure.org

    Index of all namespaces


    « Project + dependencies

    clojure.tools.loggingDocsSource
    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).
    clojure.tools.logging.implDocsSource
    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.
    clojure.tools.logging.testDocsSource
    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