Logging with Timbre
We can emit a log statement using Timbre's log
function, which accepts—at a minimum—the log level and a message to emit. The following code shows an example of an log
function.
(require '[taoensso.timbre :as timbre]) (timbre/log :info "This is an info message.") >> 2014-Nov-24 14:35:24 -0500 computer.local INFO [hipstr.handler] - This is an info message.
Alternatively, Timbre makes available a function for each logging level, thus relieving us from having to specify the log level with each call, as shown in the following code:
(timbre/info "This is an info message.")
Timbre's log
functions are similar to Clojure's str
and println
functions, as we can pass multiple strings to produce a single long string:
(timbre/info "This" "is" "an" "info" "message.")
No logging framework would be complete without the ability to log exceptions. Here is an example of appending an Exception...