Liking cljdoc? Tell your friends :D

par

A Clojure(Script) library designed to print-and-return values.

Intended to wrap existing forms in your source code so they can be observed without changing the execution of the program.

Usage

Add as a dependency to your project:

[org.clojars.paintparty/par "1.0.0"]

Import into your namespace:

(ns myns.core
  (:require
    [par.core :refer [? !? ?+ !?+]]))

;; :refer-macros syntax will work as well.
(ns myns.core
  (:require
    [par.core :refer-macros [? !? ?+ !?+]]))

?

Use the par.core/? macro to print the form and resulting value. You should expect the same console output whether you are using Clojure or ClojureScript:

(? (+ 1 2))

The above will print:

(+ 1 2) => 3

If you would like to add some commentary to your logs:

(? "Note to self" (+ 1 2))

The above will prepend the first argument to the output.
The output will be italicized, with a leading "; ".
The form that is being evaluated will not be printed:

; Note to self
 => 3

If you would like both the commentary and form to be printed:

(?+ "Note to self" :form (+ 1 2))

The above would print:

; Note to self
(+ 1 2) => 3

?+

When you want to log from inside a defmacro, or inside a function that is being called by a defmacro, the ?+ macro should be used. It has the exact same signature as ?.


!? and !?+

par.core/!? and par.core/!?+ are both no-op macros, useful when you want to temporarily silence the printing on a form that is already wrapped by ? or ?+.


License

Copyright © 2020-2021 Jeremiah Coyle

This program and the accompanying materials are made available under the terms of the Eclipse Public License 2.0 which is available at http://www.eclipse.org/legal/epl-2.0.

This Source Code may also be made available under the following Secondary Licenses when the conditions for such availability set forth in the Eclipse Public License, v. 2.0 are satisfied: GNU General Public License as published by the Free Software Foundation, either version 2 of the License, or (at your option) any later version, with the GNU Classpath Exception which is available at https://www.gnu.org/software/classpath/license.html.

Can you improve this documentation?Edit on GitHub

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

× close