refactor(logging): add subsystem console formatting
This commit is contained in:
@@ -46,10 +46,18 @@ If set, CLAWDIS derives defaults (only when you haven’t set them explicitly):
|
||||
|
||||
- Default log file: `/tmp/clawdis/clawdis-YYYY-MM-DD.log`
|
||||
- If you want a stable path, set `logging.file` to `/tmp/clawdis/clawdis.log`.
|
||||
- Console output can be tuned separately via:
|
||||
- `logging.consoleLevel` (defaults to `info`, bumps to `debug` when `--verbose`)
|
||||
- `logging.consoleStyle` (`pretty` | `compact` | `json`)
|
||||
|
||||
```json5
|
||||
{
|
||||
logging: { level: "info", file: "/tmp/clawdis/clawdis.log" }
|
||||
logging: {
|
||||
level: "info",
|
||||
file: "/tmp/clawdis/clawdis.log",
|
||||
consoleLevel: "info",
|
||||
consoleStyle: "pretty"
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
@@ -1,3 +1,10 @@
|
||||
---
|
||||
summary: "Logging surfaces, file logs, WS log styles, and console formatting"
|
||||
read_when:
|
||||
- Changing logging output or formats
|
||||
- Debugging CLI or gateway output
|
||||
---
|
||||
|
||||
# Logging
|
||||
|
||||
Clawdis has two log “surfaces”:
|
||||
@@ -53,3 +60,24 @@ clawdis gateway --verbose --ws-log compact
|
||||
# show all WS traffic (full meta)
|
||||
clawdis gateway --verbose --ws-log full
|
||||
```
|
||||
|
||||
## Console formatting (subsystem logging)
|
||||
|
||||
Clawdis formats console logs via a small wrapper on top of the existing stack:
|
||||
|
||||
- **tslog** for structured file logs (`src/logging.ts`)
|
||||
- **chalk** for colors (`src/globals.ts`)
|
||||
|
||||
The console formatter is **TTY-aware** and prints consistent, prefixed lines.
|
||||
Subsystem loggers are created via `createSubsystemLogger("gateway")`.
|
||||
|
||||
Behavior:
|
||||
|
||||
- **Subsystem prefixes** on every line (e.g. `[gateway]`, `[canvas]`, `[tailscale]`)
|
||||
- **Color only when TTY** (`process.stdout.isTTY` + `NO_COLOR` respected)
|
||||
- **Sub-loggers by subsystem** (auto prefix + structured field `{ subsystem }`)
|
||||
- **`logRaw()`** for QR/UX output (no prefix, no formatting)
|
||||
- **Console styles** (e.g. `pretty | compact | json`)
|
||||
- **Console log level** separate from file log level (file keeps full detail)
|
||||
|
||||
This keeps existing file logs stable while making interactive output scannable.
|
||||
|
||||
Reference in New Issue
Block a user