being a logging facade inspired by Rust’s log crate.
It is a simple abstraction that enables you to use the same logging functions, no matter what backend you use. You can use this abstraction to switch out your logging implementation without stress.
There are multiple functions for you to use, depending on how important the message is:
(load "git@github.com:carpentry-org/log@0.2.0")
(defn main []
(do
(Log.trace "And now for our main event...")
(while true
(if (Bool.random)
(Log.info "Heads!")
(Log.warn "Tails!"))))
)The complete set of functions, in order of severity, is:
tracedebuginfowarnerror
A log statement that the current level suppresses costs one integer comparison. The level is checked before the message is formatted, so no string is built and, importantly, the arguments are not evaluated at all: argument expressions with side effects will not run while the level suppresses the call.
To skip work that isn’t itself a log call, ask Log.enabled? directly:
(when (Log.enabled? Log.DEBUG)
(dump-diagnostics &state))A non-exhaustive list of logging backends:
simplelog: A simple logger that prints either tostdoutorstderror, depending on the log level.
Have fun!