Skip to content

Commit

Permalink
Add documentaiton to the new labeling functionality
Browse files Browse the repository at this point in the history
We add documentation on how this could be used
  • Loading branch information
mariari committed Mar 28, 2024
1 parent 9de732a commit 66f6671
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions lib/kino/process.ex
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,14 @@ defmodule Kino.Process do
target argument can either be a single PID, a list of PIDs, or the atom `:all`
depending on what messages you would like to retain in your trace.
## Options
* `:label_function` - A function to help label message events. If
the given function returns `:continue`, then the default label
is used. However, if the function returns a `String.t()`, then
that will be used for the label. To use the default labeling
logic in the given function see `label_from_value/1`.
## Examples
To generate a trace of all the messages occurring during the execution of the
Expand Down Expand Up @@ -443,6 +451,12 @@ defmodule Kino.Process do
defp label_from_reason({:shutdown, _}), do: "shutdown"
defp label_from_reason(_), do: "abnormal"

@doc """
Generates a label given a value.
This function is used in the labeling process to label values, after
the normal prefix string (CALL:, CAST:, etc.).
"""
def label_from_value(tuple)
when is_tuple(tuple) and is_atom(elem(tuple, 0)),
do: elem(tuple, 0)
Expand Down

0 comments on commit 66f6671

Please sign in to comment.