AgentForge.Debug (AgentForge v0.2.2)
View SourceProvides debug utilities for tracing and logging signals through the system.
Summary
Functions
Logs a signal's journey through the system.
Creates a debug flow that wraps each handler in debug logging.
Creates a debug handler that logs signal processing. Wraps an existing handler with debug logging.
Functions
Logs a signal's journey through the system.
Creates a debug flow that wraps each handler in debug logging.
Examples
iex> handlers = [
...> fn signal, state -> {AgentForge.Signal.emit(:step1, signal.data), state} end,
...> fn signal, state -> {AgentForge.Signal.emit(:step2, signal.data), state} end
...> ]
iex> debug_flow = AgentForge.Debug.trace_flow("test_flow", handlers)
iex> is_list(debug_flow) and length(debug_flow) == length(handlers)
true
Creates a debug handler that logs signal processing. Wraps an existing handler with debug logging.
Examples
iex> handler = fn signal, state -> {AgentForge.Signal.emit(:done, signal.data), state} end
iex> debug_handler = AgentForge.Debug.trace_handler("test", handler)
iex> signal = AgentForge.Signal.new(:test, "data")
iex> {result, _state} = debug_handler.(signal, %{})
iex> match?({:emit, %{type: :done}}, result)
true