Mooncore.MCP.Watcher
(mooncore v0.2.5)
Copy Markdown
In-memory log collector for development observability.
Stores temporary logs in a ring buffer (configurable max size). AI agents or the dev UI can add watchers, read logs, and filter by tag.
Only active when mooncore_dev_tools is enabled:
config :mooncore, mooncore_dev_tools: trueUsage
# Log an event (from anywhere in the app)
Mooncore.MCP.Watcher.log(:lifecycle, %{action: "task.create", phase: :start})
Mooncore.MCP.Watcher.log(:custom, %{message: "something happened"})
# Read all logs
Mooncore.MCP.Watcher.read()
# Read logs filtered by tag
Mooncore.MCP.Watcher.read(:lifecycle)
# Add a watcher — subscribe a PID to receive logs in real-time
Mooncore.MCP.Watcher.add_watcher(self(), :lifecycle)
# Clear logs
Mooncore.MCP.Watcher.clear()
Summary
Functions
Add a watcher PID. It will receive {:mooncore_log, tag, entry} messages.
Returns a specification to start this module under a supervisor.
Clear all logs.
Callback implementation for GenServer.init/1.
Log an event with a tag. Only stores if MOONCORE_DEV_SECRET is set.
Read all logs, optionally filtered by tag. Returns newest first.
Read logs since a given entry id.
Remove a watcher PID.
Get watcher count.
Functions
Add a watcher PID. It will receive {:mooncore_log, tag, entry} messages.
Returns a specification to start this module under a supervisor.
See Supervisor.
Clear all logs.
Callback implementation for GenServer.init/1.
Log an event with a tag. Only stores if MOONCORE_DEV_SECRET is set.
Read all logs, optionally filtered by tag. Returns newest first.
Read logs since a given entry id.
Remove a watcher PID.
Get watcher count.