# _output

URL: /pounce/api/_output/
Section: api
Description: Kida template infrastructure and one-shot branded output.

Provides the shared template environment, thread-safe stderr writer, and
branded renders for CLI commands (error, info, check, traceback) and access
logs.  Server lifecycle output (banner, ready, shutdown, reload, worker
events) is handled by the dispatch-driven view layer in ``_state.py``.

---

> For a complete page index, fetch /pounce/llms.txt.

Open LLM text
(/pounce/api/_output/index.txt)

Share with AI

Ask Claude
(https://claude.ai/new?q=Please%20help%20me%20understand%20this%20documentation%3A%20%2Fpounce%2Fapi%2F_output%2Findex.txt)

Ask ChatGPT
(https://chatgpt.com/?q=Please%20help%20me%20understand%20this%20documentation%3A%20%2Fpounce%2Fapi%2F_output%2Findex.txt)

Ask Gemini
(https://gemini.google.com/app?q=Please%20help%20me%20understand%20this%20documentation%3A%20%2Fpounce%2Fapi%2F_output%2Findex.txt)

Ask Copilot
(https://copilot.microsoft.com/?q=Please%20help%20me%20understand%20this%20documentation%3A%20%2Fpounce%2Fapi%2F_output%2Findex.txt)

Module

#
`_output`

Kida template infrastructure and one-shot branded output.

Provides the shared template environment, thread-safe stderr writer, and
branded renders for CLI commands (error, info, check, traceback) and access
logs. Server lifecycle output (banner, ready, shutdown, reload, worker
events) is handled by the dispatch-driven view layer in`_state.py`.

19Functions

## Functions

`_get_env`

0

▼

Get or create the kida template environment (thread-safe, lazy).

`def _get_env()`

`_is_pretty`

0

`bool`

▼

Check if we're in pretty (TTY) output mode.

`def _is_pretty() -> bool`

##### Returns

`bool`

`_render`

2

`str`

▼

Render a kida template with the given context.

`def _render(name: str, **ctx) -> str`

##### Parameters

Name
Type
Description

`name`
`str`

`**ctx`
`—`

##### Returns

`str`

`_write`

1

`None`

▼

Write a line to stderr (thread-safe).

Reuses the shared lock from pounce.loggi…

`def _write(text: str) -> None`

Write a line to stderr (thread-safe).

Reuses the shared lock from pounce.logging so lifecycle output and
direct stderr writes (JSON mode, etc.) never interleave under
free-threaded Python.

##### Parameters

Name
Type
Description

`text`
`str`

`_write_stdout`

1

`None`

▼

Write a line to stdout (thread-safe).

Diagnostic commands (``pounce info``) em…

`def _write_stdout(text: str) -> None`

Write a line to stdout (thread-safe).

Diagnostic commands (`pounce info`) emit to stdout so output is captured
by`pounce info | cat` / `| jq`rather than silently dropped through an
unconfigured logger. Reuses the shared stderr lock so interleaving with
lifecycle output stays serialized under free-threaded Python.

##### Parameters

Name
Type
Description

`text`
`str`

`error`

5

`None`

▼

Render a branded error message.

Uses the kida template when stderr is a TTY (e…

`def error(message: str, *, code: str | None = None, hint: str | None = None, docs_url: str | None = None, diagnostics: list[dict[str, str]] | None = None) -> None`

Render a branded error message.

Uses the kida template when stderr is a TTY (even if logging hasn't
been configured yet — errors can fire before configure_logging runs).
Falls back to plain text when piped.

##### Parameters

Name
Type
Description

`message`
`str`

`code`
`str | None`

Default:`None`

`hint`
`str | None`

Default:`None`

`docs_url`
`str | None`

Default:`None`

`diagnostics`
`list[dict[str, str]] | None`

Default:`None`

`_human_bytes`

1

`str`

▼

Format byte count for human readability.

`def _human_bytes(n: int) -> str`

##### Parameters

Name
Type
Description

`n`
`int`

##### Returns

`str`

`_duration_str`

1

`str`

▼

Format duration in human-readable form.

`def _duration_str(ms: float) -> str`

##### Parameters

Name
Type
Description

`ms`
`float`

##### Returns

`str`

`access`

6

`None`

▼

Render a pretty-mode access log line via kida template.

`def access(method: str, path: str, status: int, bytes_sent: int, duration_ms: float, client: str) -> None`

##### Parameters

Name
Type
Description

`method`
`str`

`path`
`str`

`status`
`int`

`bytes_sent`
`int`

`duration_ms`
`float`

`client`
`str`

`detect_gil_status`

0

`str`

▼

Detect whether the GIL is enabled or disabled.

`def detect_gil_status() -> str`

##### Returns

`str`

`probe_optional_dep`

1

`tuple[bool, str]`

▼

Check if an optional dependency is importable and return its version.

`def probe_optional_dep(module: str) -> tuple[bool, str]`

##### Parameters

Name
Type
Description

`module`
`str`

##### Returns

`tuple[bool, str]`

`probe_all_optional_deps`

0

`list[dict]`

▼

Probe all optional dependencies, returning status dicts for rendering.

`def probe_all_optional_deps() -> list[dict]`

##### Returns

`list[dict]`

`detect_frameworks`

0

`list[str]`

▼

Detect installed ASGI frameworks by attempting imports.

`def detect_frameworks() -> list[str]`

##### Returns

`list[str]`

`detect_worker_model`

0

`str`

▼

Describe the worker model auto-detect would choose on this interpreter.

Combin…

`def detect_worker_model() -> str`

Describe the worker model auto-detect would choose on this interpreter.

Combines the spawning strategy (`detect_worker_mode` (/pounce/api/_runtime/#detect_worker_mode)()) with the
execution mode (`resolve_worker_execution_mode` (/pounce/api/_runtime/#resolve_worker_execution_mode)()) so the line reflects
what`--worker-mode auto` would pick here — e.g. `thread (sync)`on a
free-threaded build,`process (async)`on a GIL build.

##### Returns

`str`

`info_panel`

11

`None`

▼

Render the system info diagnostic panel.

Writes to stdout (via `_write_stdout`…

`def info_panel(*, version: str, python_version: str, platform_str: str, cpu_count: int, gil_status: str, install_path: str, deps: list[dict], frameworks: list[str], worker_model: str, worker_count: int, output_format: str = 'text') -> None`

Render the system info diagnostic panel.

Writes to stdout (via `_write_stdout` (/pounce/api/_output/#_write_stdout)()) so the diagnostics survive
being piped or redirected —`pounce info`previously emitted via
`logger.info` (/pounce/api/_cli/#info), which is dropped when no handler is installed (the common
non-TTY automation case).

`output_format` selects the channel: `"json"`emits a stable,
machine-readable dict; anything else renders the human-readable panel
(pretty when stderr is a TTY, plain text otherwise).

##### Parameters

Name
Type
Description

`version`
`str`

`python_version`
`str`

`platform_str`
`str`

`cpu_count`
`int`

`gil_status`
`str`

`install_path`
`str`

`deps`
`list[dict]`

`frameworks`
`list[str]`

`worker_model`
`str`

`worker_count`
`int`

`output_format`
`str`

Default:`'text'`

`check_results`

3

`None`

▼

Render pre-flight check results.

`def check_results(*, version: str, checks: list[dict], all_passed: bool) -> None`

##### Parameters

Name
Type
Description

`version`
`str`

`checks`
`list[dict]`

`all_passed`
`bool`

`_shorten_path`

1

`str`

▼

Shorten a file path for display.

`def _shorten_path(filepath: str) -> str`

##### Parameters

Name
Type
Description

`filepath`
`str`

##### Returns

`str`

`_hint_for_crash`

1

`str`

▼

Generate a contextual hint for common crash patterns.

`def _hint_for_crash(exc: BaseException) -> str`

##### Parameters

Name
Type
Description

`exc`
`BaseException`

##### Returns

`str`

`branded_traceback`

2

`None`

▼

Render a branded traceback for an unhandled exception.

`def branded_traceback(exc: BaseException, *, worker_id: int | None = None) -> None`

##### Parameters

Name
Type
Description

`exc`
`BaseException`

`worker_id`
`int | None`

Default:`None`
