taoensso.timbre
Simple, flexible, all-Clojure logging. No XML!
color-str
(color-str color & xs)
compile-config
Implementation detail.
Returns {:appenders-juxt {<level> <wrapped-juxt or nil>}
:ns-filter (fn relevant-ns? [ns])}.
debug
macro
(debug & message)
(debug throwable & message)
Logs at :debug level using print-style args.
debugf
macro
(debugf fmt & fmt-args)
(debugf throwable fmt & fmt-args)
Logs at :debug level using format-style args.
default-args-hash-fn
(default-args-hash-fn {:keys [hostname ns args], :as apfn-args})
Alpha - subject to change!!
Returns a hash identifier for given appender arguments in such a way that
(= (hash args-A) (hash args-B)) iff arguments A and B are "the same" by
some reasonable-in-the-general-case definition for logging arguments.
Useful in the context of rate limiting, deduplicating appenders, etc.
default-fmt-output-fn
(default-fmt-output-fn {:keys [level throwable message timestamp hostname ns]} & [{:keys [nofonts?], :as appender-fmt-output-opts}])
error
macro
(error & message)
(error throwable & message)
Logs at :error level using print-style args.
errorf
macro
(errorf fmt & fmt-args)
(errorf throwable fmt & fmt-args)
Logs at :error level using format-style args.
example-config
APPENDERS
An appender is a map with keys:
:doc ; (Optional) string.
:min-level ; (Optional) keyword, or nil (no minimum level).
:enabled? ; (Optional).
:async? ; (Optional) dispatch using agent (good for slow appenders).
:rate-limit ; (Optional) [ncalls-limit window-ms].
:fmt-output-opts ; (Optional) extra opts passed to `fmt-output-fn`.
:fn ; (fn [appender-args-map]), with keys described below.
:args-hash-fn ; Experimental. Used by rate-limiter, etc.
An appender's fn takes a single map with keys:
:level ; Keyword.
:error? ; Is level an 'error' level?
:throwable ; java.lang.Throwable.
:args ; Raw logging macro args (as given to `info`, etc.).
:message ; Stringified logging macro args, or nil.
:output ; Output of `fmt-output-fn`, used by built-in appenders
; as final, formatted appender output. Appenders may (but
; are not obligated to) use this as their output.
:ap-config ; Content of config's :shared-appender-config key.
:profile-stats ; From `profile` macro.
:instant ; java.util.Date.
:timestamp ; String generated from :timestamp-pattern, :timestamp-locale.
:hostname ; String.
:ns ; String.
;; Waiting on http://dev.clojure.org/jira/browse/CLJ-865:
:file ; String.
:line ; Integer.
MIDDLEWARE
Middleware are fns (applied right-to-left) that transform the map
dispatched to appender fns. If any middleware returns nil, no dispatching
will occur (i.e. the event will be filtered).
The `example-config` code contains further settings and details.
See also `set-config!`, `merge-config!`, `set-level!`.
fatal
macro
(fatal & message)
(fatal throwable & message)
Logs at :fatal level using print-style args.
fatalf
macro
(fatalf fmt & fmt-args)
(fatalf throwable fmt & fmt-args)
Logs at :fatal level using format-style args.
get-compile-time-ns
macro
(get-compile-time-ns)
get-default-config
(get-default-config)
green
DEPRECATED: Use `color-str` instead.
info
macro
(info & message)
(info throwable & message)
Logs at :info level using print-style args.
infof
macro
(infof fmt & fmt-args)
(infof throwable fmt & fmt-args)
Logs at :info level using format-style args.
level-compile-time
Constant, compile-time logging level determined by the `TIMBRE_LOG_LEVEL`
environment variable. When set, overrules dynamically-configurable logging
level as a performance optimization.
level-sufficient?
(level-sufficient? level config)
Precendence: compile-time > dynamic > config > atom.
log
macro
(log level & message)
(log level throwable & message)
(log config level & message)
(log config level throwable & message)
Logs using print-style args. Takes optional logging config (defaults to
`timbre/@config`.)
log*
macro
(log* base-appender-args msg-type level & log-args)
(log* base-appender-args msg-type config level & log-args)
log-and-rethrow-errors
macro
(log-and-rethrow-errors & body)
log-errors
macro
(log-errors & body)
logf
macro
(logf level fmt & fmt-args)
(logf level throwable fmt & fmt-args)
(logf config level fmt & fmt-args)
(logf config level throwable fmt & fmt-args)
Logs using format-style args. Takes optional logging config (defaults to
`timbre/@config`.)
logged-future
macro
(logged-future & body)
logging-enabled?
(logging-enabled? level & [compile-time-ns])
For 3rd-party utils, etc.
logp
macro
(logp level & message)
(logp level throwable & message)
DEPRECATED: Use `log` instead.
merge-config!
(merge-config! & maps)
ns-unfiltered?
(ns-unfiltered? config ns)
red
DEPRECATED: Use `color-str` instead.
refer-timbre
(refer-timbre)
Shorthand for:
(require
'[taoensso.timbre :as timbre
:refer (log trace debug info warn error fatal report
logf tracef debugf infof warnf errorf fatalf reportf
spy logged-future with-log-level with-logging-config
sometimes)])
(require
'[taoensso.timbre.profiling :as profiling
:refer (pspy pspy* profile defnp p p*)])
report
macro
(report & message)
(report throwable & message)
Logs at :report level using print-style args.
reportf
macro
(reportf fmt & fmt-args)
(reportf throwable fmt & fmt-args)
Logs at :report level using format-style args.
s
macro
(s expr)
(s level expr)
(s level name expr)
DEPRECATED: Use `spy` instead.
send-to-appenders!
(send-to-appenders! level base-appender-args log-vargs ns throwable message & [juxt-fn msg-type file line])
set-config!
(set-config! ks val)
set-level!
(set-level! level)
sometimes
macro
(sometimes probability & body)
Executes body with probability e/o [0,1]. Useful for sampled logging.
spy
macro
(spy expr)
(spy level expr)
(spy level name expr)
Evaluates named expression and logs its result. Always returns the result.
Defaults to :debug logging level and unevaluated expression as name.
stacktrace
(stacktrace throwable & [separator stacktrace-fonts])
Default stacktrace formatter for use by appenders, etc.
str-println
(str-println & xs)
Like `println` but prints all objects to output stream as a single
atomic string. This is faster and avoids interleaving race conditions.
trace
macro
(trace & message)
(trace throwable & message)
Logs at :trace level using print-style args.
tracef
macro
(tracef fmt & fmt-args)
(tracef throwable fmt & fmt-args)
Logs at :trace level using format-style args.
warn
macro
(warn & message)
(warn throwable & message)
Logs at :warn level using print-style args.
warnf
macro
(warnf fmt & fmt-args)
(warnf throwable fmt & fmt-args)
Logs at :warn level using format-style args.
with-default-outs
macro
(with-default-outs & body)
Evaluates body with Clojure's default *out* and *err* bindings.
with-err-as-out
macro
(with-err-as-out & body)
Evaluates body with *err* bound to *out*.
with-log-level
macro
(with-log-level level & body)
Allows thread-local config logging level override. Useful for dev & testing.
with-logging-config
macro
(with-logging-config config & body)
Allows thread-local logging config override. Useful for dev & testing.
yellow
DEPRECATED: Use `color-str` instead.