Skip to content

Commit e6dabab

Browse files
authored
feat: add output logs docs (#170)
1 parent cd3adce commit e6dabab

File tree

2 files changed

+78
-0
lines changed

2 files changed

+78
-0
lines changed

docs/features/file-logging.mdx

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
---
2+
title: Structured File Logs
3+
description: Persist Zephyr build output as structured files for easier debugging, CI archiving, and log ingestion.
4+
head:
5+
- - meta
6+
- property: og:description
7+
content: Persist Zephyr build output as structured files for easier debugging, CI archiving, and log ingestion.
8+
---
9+
10+
# Structured File Logs
11+
12+
Zephyr build integrations now support structured, file-based logging for every build run. When enabled, logs are written to disk in addition to the terminal, making it easier to debug build issues locally and to store artifacts from CI.
13+
14+
## Quick start
15+
16+
- Enable logging for a single command:
17+
18+
```bash
19+
ZEPHYR_LOG_TO_FILE=true pnpm build
20+
```
21+
22+
- Choose TOON encoding instead of JSON:
23+
24+
```bash
25+
ZEPHYR_LOG_TO_FILE=true ZEPHYR_LOG_FORMAT=toon pnpm build
26+
```
27+
28+
- Override the default log directory:
29+
30+
```bash
31+
ZEPHYR_LOG_TO_FILE=true ZEPHYR_LOG_PATH=/tmp/zephyr-logs pnpm build
32+
```
33+
34+
## Where logs are stored
35+
36+
- **Default path:** `~/.zephyr/logs/` (override with `ZEPHYR_LOG_PATH`)
37+
- **Per-run folders:** Each command creates `run-<timestamp>/` so logs from different runs never collide
38+
- **File naming:** Logs are split by intent to keep them targeted:
39+
- `info.log`, `warn.log`, `error.log`
40+
- `action-<action>.log` (actions use the Zephyr log action names; colons become hyphens)
41+
- `debug-<context>.log` for `zephyr:*` debug namespaces (captured even if `DEBUG` is not set)
42+
- **Summary:** When the CLI writes run metadata, it is saved to `summary.json` with timestamps, duration, build ID, and any reported counts.
43+
44+
### Example layout
45+
46+
```
47+
~/.zephyr/logs/run-2024-06-14T18-22-05/
48+
info.log
49+
warn.log
50+
error.log
51+
action-build.log
52+
debug-git.log
53+
summary.json
54+
```
55+
56+
## Log formats
57+
58+
- **JSON (default):** One JSON object per line with `level`, `message`, `timestamp`, `action`, and any structured payloads.
59+
- **TOON:** Set `ZEPHYR_LOG_FORMAT=toon` to emit [TOON](https://www.npmjs.com/package/@toon-format/toon) encoded entries for downstream tooling that prefers the format.
60+
61+
## Structured payload extraction
62+
63+
- When a log line contains valid JSON (for example, API responses), the builder separates the text from the parsed payload:
64+
- `message` keeps the human-readable text
65+
- `payload` contains the parsed JSON object or array
66+
- ANSI color codes are stripped before writing, so files stay clean for parsers and artifact viewers.
67+
68+
## CI recommendations
69+
70+
- Turn on file logging for build steps where you already capture artifacts: `ZEPHYR_LOG_TO_FILE=1`
71+
- Set `ZEPHYR_LOG_PATH` to a workspace-relative folder (e.g., `./artifacts/zephyr-logs`) so your pipeline can zip and upload it
72+
- Keep `DEBUG` off if you do not want verbose console output—debug namespaced logs are still captured on disk when file logging is enabled
73+
74+
With file logging enabled, every Zephyr build run produces durable, structured logs you can inspect locally, attach to bug reports, or feed into your log processing pipeline.

rspress.config.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,10 @@ const sidebar: Sidebar = {
8989
text: 'Remote Dependencies',
9090
link: '/features/remote-dependencies',
9191
},
92+
{
93+
text: 'Structured File Logs',
94+
link: '/features/file-logging',
95+
},
9296
{
9397
text: 'CI/CD - Personal token',
9498
link: '/features/ci-cd-personal-token',

0 commit comments

Comments
 (0)