Home

Awesome

clojure.tools.trace

A Clojure trace tool. Defines tracing macros/fns to help you see what your code is doing.

Formerly known as clojure.contrib.trace.

See the tools.trace API Reference.

Releases and Dependency Information

Latest stable release: 0.8.0

CLI/deps.edn dependency information:

org.clojure/tools.trace {:mvn/version "0.8.0"}

Leiningen dependency information:

    [org.clojure/tools.trace "0.8.0"]

Maven dependency information:

    <dependency>
      <groupId>org.clojure</groupId>
      <artifactId>tools.trace</artifactId>
      <version>0.8.0</version>
    </dependency>

Example Usage

=> (use 'clojure.tools.trace)

=> (trace (* 2 3)) ;; To trace a value
TRACE: 6
6

=> (trace "tag" (* 2 3)) ;; To trace a value and assign a trace tag
TRACE tag: 6
6

=> (deftrace fubar [x v] (+ x v)) ;; To trace a function call and its return value
=> (fubar 2 3)
TRACE t1107: (fubar 2 3)
TRACE t1107: => 5
5

=> (do (+ 1 3) (* 5 6) (/ 1 0))
ArithmeticException Divide by zero  clojure.lang.Numbers.divide (Numbers.java:156)
=> (trace-forms (+ 1 3) (* 5 6) (/ 1 0)) ;; To identify which form is failing
ArithmeticException Divide by zero
  Form failed: (/ 1 0)
  clojure.lang.Numbers.divide (Numbers.java:156)

(trace-ns myown.namespace) ;; To dynamically trace/untrace all fns in a name space (untrace-ns myown.namespace)

(trace-vars myown.namespace/fubar) ;; To dynamically trace/untrace specific fns (untrace-vars myown.namespace/fubar)
 

Developer Information

Change Log

Copyright and License

Copyright (c) Stuart Sierra, Michel Salim, Luc Préfontaine, Jonathan Fischer Friberg, Michał Marczyk, Andy Fingerhut. All rights reserved. The use and distribution terms for this software are covered by the Eclipse Public License 1.0 (https://opensource.org/license/epl-1-0/) which can be found in the file epl-v10.html at the root of this distribution. By using this software in any fashion, you are agreeing to be bound by the terms of this license. You must not remove this notice, or any other, from this software.