taoensso.timbre

Simple, flexible logging for Clojure/Script. No XML.

*config*

dynamic

See `example-config` for info.

*context*

dynamic

General-purpose dynamic logging context. Context will be included in appender
data map at logging time.

color-str

(color-str color & xs)

debug

macro

(debug & args)

debugf

macro

(debugf & args)

default-data-hash-fn

(default-data-hash-fn data)
Used for rate limiters, some appenders (e.g. Carmine), etc.
Goal: (hash data-1) = (hash data-2) iff data-1 "the same" as data-2 for
rate-limiting purposes, etc.

default-err

default-out

default-output-fn

(default-output-fn data)(default-output-fn {:keys [no-stacktrace? stacktrace-fonts], :as opts} data)
Default (fn [data]) -> string output fn.
You can modify default options with `(partial default-output-fn <opts-map>)`.

default-timestamp-opts

Controls (:timestamp_ data)

error

macro

(error & args)

errorf

macro

(errorf & args)

example-config

Example (+default) Timbre v4 config map.

APPENDERS
  An appender is a map with keys:
    :min-level       ; Level keyword, or nil (=> no minimum level)
    :enabled?        ;
    :async?          ; Dispatch using agent? Useful for slow appenders
    :rate-limit      ; [[ncalls-limit window-ms] <...>], or nil
    :output-fn       ; Optional override for inherited (fn [data]) -> string
    :fn              ; (fn [data]) -> side effects, with keys described below

  An appender's fn takes a single data map with keys:
    :config          ; Entire config map (this map, etc.)
    :appender-id     ; Id of appender currently dispatching
    :appender        ; Entire map of appender currently dispatching

    :instant         ; Platform date (java.util.Date or js/Date)
    :level           ; Keyword
    :error-level?    ; Is level e/o #{:error :fatal}?
    :?ns-str         ; String, or nil
    :?file           ; String, or nil  ; Waiting on CLJ-865
    :?line           ; Integer, or nil ; Waiting on CLJ-865

    :?err_           ; Delay - first-arg platform error, or nil
    :vargs_          ; Delay - raw args vector
    :hostname_       ; Delay - string (clj only)
    :msg_            ; Delay - args string
    :timestamp_      ; Delay - string
    :output-fn       ; (fn [data]) -> formatted output string
                     ; (see `default-output-fn` for details)

    :context         ; *context* value at log time (see `with-context`)
    :profile-stats   ; From `profile` macro

MIDDLEWARE
  Middleware are simple (fn [data]) -> ?data fns (applied left->right) that
  transform the data map dispatched to appender fns. If any middleware returns
  nil, NO dispatching will occur (i.e. the event will be filtered).

The `example-config` source code contains further settings and details.
See also `set-config!`, `merge-config!`, `set-level!`.

fatal

macro

(fatal & args)

fatalf

macro

(fatalf & args)

get-env

macro

(get-env)

get-hostname

handle-uncaught-jvm-exceptions!

(handle-uncaught-jvm-exceptions! & [handler])
Sets JVM-global DefaultUncaughtExceptionHandler.

info

macro

(info & args)

infof

macro

(infof & args)

level>=

(level>= x y)

log

macro

(log level & args)

log*

macro

(log* config level & args)

log-and-rethrow-errors

macro

(log-and-rethrow-errors & body)

log-env

macro

(log-env)(log-env level)(log-env level name)(log-env config level name)
Logs named &env value.
Defaults to :debug logging level and "&env" as name.

log-errors

macro

(log-errors & body)

log1-fn

(log1-fn config level ?ns-str ?file ?line msg-type vargs_ ?base-data)
Core fn-level logger. Implementation detail!

log1-macro

macro

(log1-macro config level msg-type args & [?base-data])
Core macro-level logger. Implementation detail!

log?

(log? level & [?ns-str config])
Would Timbre currently log at the given logging level?
* Compile-time `?ns-str` arg required to support ns filtering.
* `config` arg required to support non-global config.

logf

macro

(logf level & args)

logf*

macro

(logf* config level & args)

logged-future

macro

(logged-future & body)

logging-enabled?

(logging-enabled? level compile-time-ns)

logp

macro

(logp & sigs)

merge-config!

(merge-config! m)

ordered-levels

println-appender

(println-appender & [{:keys [stream], :or {stream :auto}}])
Returns a simple `println` appender for Clojure/Script.
Use with ClojureScript requires that `cljs.core/*print-fn*` be set.

:stream (clj only) - e/o #{:auto :*out* :*err* :std-err :std-out <io-stream>}.

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 get-env log-env)])
(require '[taoensso.timbre.profiling :as profiling
           :refer (pspy pspy* profile defnp p p*)])

report

macro

(report & args)

reportf

macro

(reportf & args)

set-config!

(set-config! m)

set-level!

(set-level! level)

sometimes

macro

(sometimes probability & body)
Handy for sampled logging, etc.

spit-appender

(spit-appender & [{:keys [fname], :or {fname "./timbre-spit.log"}}])
Returns a simple `spit` file appender for Clojure.

spy

macro

(spy expr)(spy level expr)(spy level name expr)(spy config 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 err & [{:keys [stacktrace-fonts], :as opts}])

str-println

(str-println & xs)

swap-config!

(swap-config! f & args)

trace

macro

(trace & args)

tracef

macro

(tracef & args)

warn

macro

(warn & args)

warnf

macro

(warnf & args)

with-config

macro

(with-config config & body)

with-context

macro

(with-context context & body)

with-default-outs

macro

(with-default-outs & body)

with-level

macro

(with-level level & body)

with-log-level

macro

(with-log-level level & body)

with-logging-config

macro

(with-logging-config config & body)

with-merged-config

macro

(with-merged-config config & body)