Skip to content

Print capture

Forward print() / sys.stdout / sys.stderr writes to AxonPush as agent.log events. Use this for AI agent projects where the agent (or its tools) emits free-form output via print() — the AxonPush wizard wires this up automatically for detected agent projects so that any print call shows up in the trace timeline.

The tee stream always writes to the original console first, so your existing terminal output is unchanged. It then buffers the output until it sees a newline and emits one event per line, so multi-write print() calls don’t get fragmented across events.

Terminal window
pip install axonpush

No extras needed — stdlib only.

import os
from axonpush import AxonPush
from axonpush.integrations.print_capture import setup_print_capture
client = AxonPush(
api_key=os.environ["AXONPUSH_API_KEY"],
tenant_id=os.environ["AXONPUSH_TENANT_ID"],
)
handle = setup_print_capture(
client,
channel_id=1,
agent_id="my-agent",
service_name="my-agent",
)
# Captured AND written to the original console
print("agent starting up")
print("step 1: loaded tools = ['web_search', 'calculator']")
print("step 2: calling model")
# Also captures writes to sys.stderr
import sys
print("warning: retrying after 429", file=sys.stderr)
handle.unpatch() # restores the original sys.stdout / sys.stderr

Always unpatch() in a finally: block (or use the handle at the end of a with context) so that test teardown and subprocess spawning don’t inherit the tee stream.

FieldValue
identifierstdout.write or stderr.write
event_typeagent.log (default) or app.log if source="app"
payload.bodyThe captured line (trailing newline stripped)
payload.severityNumber / payload.severityTextINFO for stdout, ERROR for stderr
payload.attributesstream.name (stdout / stderr)
payload.resourceservice.name (if configured)