a tiny logfmt emitter for clojure
Clojure Shell
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.



A Clojure library for emitting logfmt, a logging format initially designed at heroku. Sample logfmt output:

method=get path=/ status=200 duration=0ms




There are 4 main pieces to the api:

  • msg : takes a sequence of k/v pairs like so (msg :foo 1) and returns a string
  • map->msg : turns a map into a logfmt string
  • out : takes a sequence of k/v pairs like so (out :foo 1) and prints them on stdout
  • err : takes a sequence of k/v pairs like so (out :foo 1) and prints them on stderr

The last two are macros that expand a reasonable amount of string concatenation at compile time.

Why Isn't it a map?

This is literally the only clojure api I've ever released that doesn't use a map for what is conceptually a map of options. This is because, for logfmt, you really want the order of your keys to be the same across calls, otherwise your logs get impossible to read. That could be accomplished with sorting the keys before printing, but I wanted to have actual control over that order as well.

Ring Middleware

There's also a ring middleware that wraps logging in this style (to stdout), logfmt.ring/wrap-logging Output looks like this:

method=get path=/ status=200 duration=0ms

This isn't meant to be an general purpose logging library or anything, it was literally built for the environment yeller runs in - all apps emit logs on stdout/stderr, and is piped into something else that does log rotation, timestamp prepending etc. This is a very similar environment to Heroku, so this may be useful there as well.


Copyright © 2014 FIXME

Distributed under the Eclipse Public License version 1.0