Git Product home page Git Product logo

cljs-console's Introduction

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.

Char Format Mnemonic Example
~ %s Clojure unquote "data: ~(:data x)"
# %d ints are numbers "found #{count} things"
. %f floats have points "money = $.{amount}"
' %s strings are quoted "hello, '(:name person)"
< %o xml has <> "doc: <{js/document}"
@ %O looks like big-O "status: @{some-js-obj}"
^ %c nobody 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.

cljs-console's People

Contributors

micha avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

cljs-console's Issues

Bump adzerk/env?

I noticed some warning when I am using this in conjunction with another adzerk/env in the deps. I can use :exclusions but I was wondering whether we can bump it?

I can send a PR.

group- does emit code when the body is not emitted

(log/group- "event processed '(name (first event-v)) ('(count event-q)))"
               (log/debug "~{event-v} events remaining: #(count event-q)"))

When compiled for level warn, the group- message is in the compiled code when it should not.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.