mirror of
https://github.com/taoensso/telemere.git
synced 2025-12-25 21:08:25 +00:00
44 lines
1.7 KiB
Text
44 lines
1.7 KiB
Text
"Spy" signal creator, emphasizing form + level.
|
|
|
|
API: [form] [level-or-opts form] => form's result (value/throw) (unconditional)
|
|
Default kind: `:spy`
|
|
Default level: `:info`
|
|
|
|
When filtering conditions are met [4], creates a Telemere signal [3] and
|
|
dispatches it to registered handlers for processing (e.g. writing to
|
|
console/file/queue/db, etc.).
|
|
|
|
`form` is generally expected to be synchronous and eager (not a lazy seq,
|
|
async call, or IOT code like a core.async `go` block, etc.).
|
|
|
|
Examples:
|
|
|
|
(spy! (+ 1 2)) ; %> {:kind :trace, :level :info, :run-form '(+ 1 2),
|
|
; :run-val 3, :run-nsecs <int>, :parent {:keys [id uid]}
|
|
; :msg "(+ 1 2) => 3" ...}
|
|
(spy! ::my-id (+ 1 2)) ; %> {... :id ::my-id ...}
|
|
(spy!
|
|
{:let [x "x"] ; Available to `:data` and `:msg`
|
|
:data {:x x}}
|
|
|
|
(+ 1 2)) ; %> {... :data {x "x"}, :msg_ "My msg: x" ...}
|
|
|
|
Tips:
|
|
|
|
- Test using `with-signal`: (with-signal (spy! ...)).
|
|
- Supports the same options [2] as other signals [1].
|
|
|
|
- Identical to `trace!`, but emphasizes form + level rather than form + id.
|
|
|
|
- Useful for debugging/monitoring forms, and tracing (nested) execution flow.
|
|
- Execution of `form` arg may create additional (nested) signals.
|
|
Each signal's `:parent` key will indicate its immediate parent.
|
|
|
|
- Can be useful to wrap with `catch->error!`:
|
|
(catch->error! ::error-id (spy! ...)).
|
|
|
|
----------------------------------------------------------------------
|
|
[1] See `help:signal-creators` - (`signal!`, `log!`, `event!`, ...)
|
|
[2] See `help:signal-options` - {:keys [kind level id data ...]}
|
|
[3] See `help:signal-content` - {:keys [kind level id data ...]}
|
|
[4] See `help:signal-filters` - (by ns/kind/id/level, sampling, etc.)
|