Skip to content
carpentry-orgPublic

About

A logging facade for Carp

Resources

Stars

1 star

Watchers

1 watching

Forks

Latest commit

 

History

37 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 

Repository files navigation

log

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.

Usage

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:

  • trace
  • debug
  • info
  • warn
  • error

Evaluation

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))

Backends

A non-exhaustive list of logging backends:

  • simplelog: A simple logger that prints either to stdout or stderror, depending on the log level.

Have fun!

About

A logging facade for Carp

Resources

Stars

1 star

Watchers

1 watching

Forks

Releases

Packages

Contributors