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.
;; 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:

Note The data produced by
portal.consoleis compatible with theportal.runtime.jvm.editor/goto-definitioncommand which can automatically open the file location via the:launcher/:editoroption passed toportal.api/open.
If you could like the generate data for the log viewer in another context, the following specs will be useful:
(def levels
[:trace :debug :info :warn :error :fatal :report])
(s/def ::level (set levels))
(s/def ::ns symbol?)
(s/def ::time inst?)
(s/def ::column int?)
(s/def ::line int?)
(s/def ::log
(s/keys :req-un
[::level
::ns
::time
::line
::column]))
Can you improve this documentation?Edit on GitHub
cljdoc builds & hosts documentation for Clojure/Script libraries
| Ctrl+k | Jump to recent docs |
| ← | Move to previous article |
| → | Move to next article |
| Ctrl+/ | Jump to the search field |