> ## Documentation Index
> Fetch the complete documentation index at: https://docs.ns.rocks/llms.txt
> Use this file to discover all available pages before exploring further.

# Template Build Logging Migration

> Move older template build code to the current structured logging surface.

Current template builds stream structured log entries for both blocking and
background workflows. Use `on_log_entry=` when you need progress output.

## Blocking logs

```python theme={"theme":{"light":"one-light","dark":"one-dark-pro"}}
from nullspace import Template

def log(entry):
    print(entry.level, entry.message)

Template.build(
    Template.from_python_image("3.12").run_cmd("python --version"),
    "python-dev",
    on_log_entry=log,
)
```

## Background logs

```python theme={"theme":{"light":"one-light","dark":"one-dark-pro"}}
build = Template.build_in_background(
    Template.from_python_image("3.12"),
    name="python-dev",
)
final = build.wait_until_terminal(on_log_entry=log)
print(final.build.status)
```

For reconnectable consumers, persist `TemplateBuildStatusSnapshot.next_offset`
from `get_status()` and pass it as `offset=` on the next poll or wait call.

When migrating older template-build examples, keep build environment values in
`set_build_envs()` and runtime defaults in `set_runtime_envs()`.

Concept: [Create](../../concepts/create). API reference:
[buildTemplate](../../api-reference), [getTemplateBuildStatus](../../api-reference).
