log_format
log_format
¶
Agent log formatters for structured container log output.
Provides pluggable formatters that transform raw container logs (e.g. Claude stream-json NDJSON) into human-readable, color-coded terminal output.
The AgentLogFormatter protocol defines the interface: call feed_line()
for each log line, and finish() at the end for any summary output.
ClaudeStreamJsonFormatter(*, streaming=True, color=None)
¶
Formats Claude stream-json NDJSON into colored terminal output.
When streaming is True, processes content_block_start/delta/stop
events for a typewriter effect on assistant text. When False, only
processes coalesced messages (assistant, result, system).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
streaming
|
bool
|
Enable partial streaming (typewriter text deltas). |
True
|
color
|
bool | None
|
Enable ANSI colors (auto-detected from terminal if None). |
None
|
Initialise formatter with streaming and color preferences.
Source code in src/terok/lib/domain/log_format.py
feed_line(line)
¶
Parse a single NDJSON log line and print formatted output.
Source code in src/terok/lib/domain/log_format.py
finish()
¶
Flush pending output and print the result summary if available.
Source code in src/terok/lib/domain/log_format.py
auto_detect_formatter(mode, *, streaming=True, color=None, agent=None)
¶
Return the appropriate formatter for a task's mode and agent.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
mode
|
str | None
|
Task mode ( |
required |
streaming
|
bool
|
Enable partial streaming for supported formatters. |
True
|
color
|
bool | None
|
Force color on/off. |
None
|
agent
|
str | None
|
Headless agent name. When mode is |
None
|