Jota is a minimal log system for Clojure
After (require [jota.core :as log]
:
(ns myapp.core)
(log/debug "Value=" 42)
(log/error "Value=" 43)
will output:
myapp.core:debug: Value=42
myapp.core:error: Value=43
To suppress the debug-level output: (set-level! 'myapp.core :error)
or (set-level! :root :error)
Jota supports :trace, :debug, :info, :warn
and :error
, with the correspondign functions log/trace, log/debug
etc.
The standard writer is println
. You can set or add a writer:
(set-writer! 'myapp.core (fn[x] (print x)))
(add-writer! :root (fn[x] (print x)))
TODO: support logback appenders
Jota will search the level and writer for the namespace where log
is called. If not found, it will fall back to the settings of :root
. When setting levels or writers, you can use namespaces, keywords or symbol, all are mormalized to keywords. THe following are equivalent:
(set-level! *ns* :error)
(set-level! 'myapp.core :error)
(set-level! :myapp.core :error)
(set-level! "myapp.core" :error)
On startup, Jota will search jota-setting-test.clj
and jota-setting.clj
and will print the file path from which it initialized:
jota initialized from /Users/kolov/projects/jota/test/test-config.clj
A sample settings file:
{:root {:level :info}
:myapp.core {:level :debug :writer print} }