Liking cljdoc? Tell your friends :D

portal.console

A major advantage of tap> over println is that it allows you to keep all values as data. However, as with println, if you tap> too many values, it is very easy to lose track where those values came from. Luckily, there is an easy fix, clojure macros.

The portal.console namespace has a handful of macros that will not only tap> values, but capture the context in which those values are tapped. This includes source code, time and runtime information. Additionally, the data is formatted to work with the :portal.viewer/log viewer.

Example

;; user.clj
(require '[portal.console :as log])

(log/trace ::trace)
(log/debug ::debug)
(log/info  ::info)
(log/warn  ::warn)
(log/error ::error)

Will produce the following:

logs

Spec

If you could like the generate data for the log viewer in another context, the following specs will be useful:

(def ^:private levels
  [:trace :debug :info :warn :error :fatal :report])

(sp/def ::level (set levels))

(sp/def ::ns symbol?)
(sp/def ::time inst?)

(sp/def ::column int?)
(sp/def ::line int?)

(sp/def ::log
  (sp/keys :req-un
           [::level
            ::ns
            ::time
            ::line
            ::column]))

Can you improve this documentation?Edit on GitHub

cljdoc is a website building & hosting documentation for Clojure/Script libraries

× close