A ClojureScript library providing wrappers for the JavaScript console API.
A ClojureScript library providing wrappers for the JavaScript
console
API.
Add Shodan as a :dependency
in your project.clj
file.
[shodan "0.4.2"]
Console wrappers are in the shodan.console
namespace.
(ns omfg
(:require [shodan.console :as console :include-macros true])
Wrappers for console.log
, console.debug
(not available for
NodeJS), console.info
, console.warn
, console.error
.
(console/log "You move like an insect."
"You think like an insect."
"You are an insect.")
(console/debug "I have no choice but to destroy this starship.")
(console/info "Matters on Deck 5 also require your attention.")
(console/warn "I will not abide disobedience.")
(console/error "It is hopeless.")
Wrappers for console.group()
, console.groupCollapsed()
,
console.groupEnd()
.
(console/group "SHODAN")
(console/log "Launch in to the many."
"Cut out it's heart."
"And I will reward you with continued existence.")
(console/warn "Fail me, and I will put an end to your disgusting biology.")
(console/group-end)
(console/group-collapsed "SHODAN")
(console/log "Only one egg remains, insect.")
(consol/group-end)
Wrappers for console.profile(title)
and console.profileEnd()
.
;; js/console.profile
(console/profile-start "Accessing the primary data loop")
(loop [xs ["x" "y" "z"] ys (array)]
(if-let [x (first xs)]
(recur (next xs) (.push ys x))
ys))
;; js/console.profileEnd
(console/profile-end "Accessing the primary data loop")
Wrappers for console.time()
and console.timeEnd()
.
(console/time-start "Addition")
(+ 1 1)
(console/time-end "Addition")
Shodan comes with a some simple macros for message grouping, profiling, and timing.
(with-group "America Online"
(dotimes [_ 10]
(console/info "You have mail.")))
(with-group-collapsed "ERMAHRERC ERNLERN"
(dotimes [_ 10]
(console/info "U HERV MAHL.")))
(with-profile "Perf Madness"
"FIXME: Perf code here.")
(time (str "I run on beams. I run on laser beams."))
;; => Time Elapsed: 0.001ms
Inspect ClojureScript data structures and display their structure to the browser console:
(ns omfg
(:require [shodan.inspection :refer [inspect]]))
Use it just like you would clojure's clojure.pprint/pprint
:
(inspect my-super-complex-data)
Because I'm tired of copy/pasting/rewriting the same code all the time
and seeing everyone else do the same. Also, having a basic wrapper for
the console
API makes it easier to create custom logging functions
and macros.
S.H.O.D.A.N. is actually an acronym for Sentient Hyper Optimized Data Access Network. I acknowledge this library has pretty much nothing to do with any of that.
Copyright © 2013 Joel Holdbrooks
Distributed under the Eclipse Public License, the same as Clojure.