Liking cljdoc? Tell your friends :D

cljs-console

ClojureScript console logging macros.

  • No code is emitted for commands that are below the env log level.
  • Groups are only emitted when their body is not elided.
  • Support for log message formatting via string interpolation.
  • ClojureScript forms are pretty-printed.
  • Support for debugger, profiling and timing, respecting environment log level.

Usage

[adzerk/cljs-console "0.1.1"] ;; latest release

(ns foo
  (:require [adzerk.cljs-console :as log :include-macros true]))

Environment

CLJS_LOG_LEVEL={DEBUG|INFO|WARN|ERROR|NONE}

Message Formatting

String interpolation is used to generate formatted log messages. The interpolated form or expression is delimited by a control character followed by {} for atoms or () for expressions.

CharFormatMnemonicExample
~%sClojure unquote"data: ~(:data x)"
#%dints are numbers"found #{count} things"
.%ffloats have points"money = $.{amount}"
'%sstrings are quoted"hello, '(:name person)"
<%oxml has <>"doc: <{js/document}"
@%Olooks like big-O"status: @{some-js-obj}"
^%cnobody uses this"^{css-format}hi there"

Logging

;; clear the console log
(clear)

;; print to the console
(debug message)
(info message)
(warn message)
(error message)

;; group log messages
(group+ message & body) ; expanded
(group- message & body) ; collapsed

Debug Log Level Only

;; drop into the js debugger
(debugger)

;; log error if expression isn't truthy
(log-assert expression message)

;; count how many times it's called
(log-count label)

;; engage js profiling engine
(profile-start label)
(profile-end label)
(with-profile label & body)

;; record a time interval
(time-start label)
(time-end label)
(with-time label & body)

;; mark the timeline
(timestamp), (timestamp label)

;; get a stack trace
(trace object & objects)

;; inline inspection of values
(spy-> form), (spy-> form message)
(spy->> form), (spy->> message form)

Hacking

# build and install locally
boot build-jar
# push snapshot
boot build-jar push-snapshot
# push release
boot build-jar push-release

License

Copyright © 2015 Adzerk

Distributed under the Eclipse Public License either version 1.0 or (at your option) any later version.

Can you improve this documentation?Edit on GitHub

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

× close