Liking cljdoc? Tell your friends :D

callgraph.core

Runtime call stack tracing and terminal tree visualization for Clojure code.

Use with-trace around code that calls trace-call, deftraced, or deftracedmacro. The resulting trace is plain EDN and can be rendered with trace->text or trace->return-text.

Runtime call stack tracing and terminal tree visualization for Clojure code.

Use `with-trace` around code that calls `trace-call`, `deftraced`, or
`deftracedmacro`. The resulting trace is plain EDN and can be rendered with
`trace->text` or `trace->return-text`.
raw docstring

*active-trace*clj

Atom containing the active trace while with-trace is executing.

Atom containing the active trace while `with-trace` is executing.
sourceraw docstring

current-traceclj

(current-trace)

Returns the current public trace map, or an empty trace when tracing is off.

Returns the current public trace map, or an empty trace when tracing is off.
sourceraw docstring

deftracedcljmacro

(deftraced fn-name & fdecl)

Defines a fixed-arity traced function.

The declaration follows defn for docstrings, metadata, pre/post maps, and one or more fixed arities. Variadic functions can still be traced by wrapping individual calls with trace-call.

Defines a fixed-arity traced function.

The declaration follows `defn` for docstrings, metadata, pre/post maps, and
one or more fixed arities. Variadic functions can still be traced by wrapping
individual calls with `trace-call`.
sourceraw docstring

deftracedmacrocljmacro

(deftracedmacro macro-name params & body)

Defines a macro whose expanded runtime body appears as a :macro frame.

Macro arguments are shown as source forms because macros receive syntax, not evaluated values.

Defines a macro whose expanded runtime body appears as a `:macro` frame.

Macro arguments are shown as source forms because macros receive syntax, not
evaluated values.
sourceraw docstring

enter!clj

(enter! frame)

Adds a running frame to the active trace and returns the frame id.

Adds a running frame to the active trace and returns the frame id.
sourceraw docstring

finish!clj

(finish! frame-id outcome)

Completes frame-id in the active trace with outcome.

Completes `frame-id` in the active trace with `outcome`.
sourceraw docstring

(print-return-trace trace)
(print-return-trace trace options)

Prints trace as a leaf-to-root return flow and returns nil.

Options are the same as trace->return-text.

Prints `trace` as a leaf-to-root return flow and returns nil.

Options are the same as `trace->return-text`.
sourceraw docstring

(print-trace trace)
(print-trace trace options)

Prints trace as a terminal tree and returns nil.

Options are the same as trace->text.

Prints `trace` as a terminal tree and returns nil.

Options are the same as `trace->text`.
sourceraw docstring

run-frameclj

(run-frame kind name args thunk)

Runs zero-argument thunk inside a traced frame.

kind is usually :function or :macro, name is the display name, and args are the values or source forms to show in the graph.

Runs zero-argument `thunk` inside a traced frame.

`kind` is usually `:function` or `:macro`, `name` is the display name, and
`args` are the values or source forms to show in the graph.
sourceraw docstring

trace->return-textclj

(trace->return-text trace)
(trace->return-text trace options)

Renders trace as a leaf-to-root return flow string.

This view is useful for seeing how recursive leaf results recombine into parent return values. Options may include :style (:unicode or :ascii).

Renders `trace` as a leaf-to-root return flow string.

This view is useful for seeing how recursive leaf results recombine into
parent return values. Options may include `:style` (`:unicode` or `:ascii`).
sourceraw docstring

trace->textclj

(trace->text trace)
(trace->text trace options)

Renders trace as a terminal tree string.

Options may include :style (:unicode or :ascii) and :show-meta?.

Renders `trace` as a terminal tree string.

Options may include `:style` (`:unicode` or `:ascii`) and `:show-meta?`.
sourceraw docstring

trace-callcljmacro

(trace-call f & args)

Traces a single function call and labels the node as (f arg1 arg2 ..).

Traces a single function call and labels the node as `(f arg1 arg2 ..)`.
sourceraw docstring

tracing?clj

(tracing?)

Returns true when callgraph is currently collecting trace frames.

Returns true when callgraph is currently collecting trace frames.
sourceraw docstring

with-tracecljmacro

(with-trace & body)

Evaluates body with tracing enabled.

Returns {:result value :trace trace-map} when body returns normally. When body throws, the original exception is rethrown with the partial trace in (ex-data exception) under :callgraph/trace.

Evaluates `body` with tracing enabled.

Returns `{:result value :trace trace-map}` when `body` returns normally. When
`body` throws, the original exception is rethrown with the partial trace in
`(ex-data exception)` under `:callgraph/trace`.
sourceraw docstring

cljdoc builds & hosts documentation for Clojure/Script libraries

Keyboard shortcuts
Ctrl+kJump to recent docs
Move to previous article
Move to next article
Ctrl+/Jump to the search field
× close