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

36 lines
1.2 KiB
Text
Raw Normal View History

2024-04-12 12:57:24 +00:00
"Event" signal creator, focused on id + level.
2024-04-12 12:57:24 +00:00
API: [id] [id level-or-opts] => true iff signal was allowed
Default kind: `:event`
Default level: `:info`
2024-04-12 12:57:24 +00:00
When filtering conditions are met [1], creates a Telemere signal [2] and
dispatches it to registered handlers for processing (e.g. writing to
console/file/queue/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-12 12:57:24 +00:00
[1] See `help:signal-flow` docstring
[2] See `help:signal-content` docstring
[3] See `help:signal-options` docstring