telemere/resources/signal-docstrings/event!.txt

35 lines
1.2 KiB
Text
Raw Normal View History

"Event" signal call, focused on id + level.
API: [id] [id level-or-opts] => true iff signal call was allowed
Default kind: `:event`
Default level: `:info`
When conditions are met [1], creates a Telemere signal [2] and dispatches it to
registered handlers for processing (writing to console/disk/db, etc.).
Examples:
(event! ::my-id) ; %> {:kind :event, :level :info, :id ::my-id ...}
(event! ::my-id :warn) ; %> {... :level :warn ...}
(event! ::my-id
{:let [x "x"] ; Available to `:data` and `:msg`
:data {:x x}
:msg ["My msg:" x]}) ; %> {... :data {x "x"}, :msg_ "My msg: x" ...}
Tips:
- Test using `with-signal`: (with-signal (event! ...)).
- Supports the same options as other signals [3].
- A good general-purpose signal, prefer to `log!` by default, since it
better encourages structured data over unstructured messages.
- Has a different 2-arity arg order to all other signals!
Mnemonic: the arg that's typically larger is *always* in the rightmost
position, and for `event!` that's the `level-or-opts` arg.
----------------------------------------
2024-04-10 17:31:13 +00:00
[1] See `help:signal-flow` docstring
[2] See `help:signal-content` docstring
[3] See `help:signal-options` docstring