1# Logging
2
3Webette uses a structured, locale-aware logger:
4
5- Levels: `debug`, `info`, `warn`, `error` (filtered by min level).
6- Locales: `en`, `fr` (message catalogs in `locales/<lang>/logs.json`).
7- Output: console (rendered), plus `.jsonl` persistence under `<site>/<dirName>/logs.jsonl`.
8- Scoping: hierarchical (e.g., `webette.cli.serve.build`).
9
10## Configuration
11
12- Locale and min level come from the tool config (`webette.tool.ts`) via `getEnv()` / `resolveLocale()`.
13- `logging.dirName` controls where logs are written inside the **site** root (default `.webette`).
14- Verbose flag (`-v`) forces `debug` min level.
15
16## API
17
18- `createProjectLogger(rootDir, scope, verbose)` → Logger (async).
19- `logger.child(scope)` → child logger sharing config and log file.
20- Methods: `debug`, `info`, `warn`, `error` accept a `messageKey` plus optional params.
21
22## Messages
23
24- Keys and templates live in `locales/en/logs.json` and `locales/fr/logs.json`.
25- Interpolation uses `{name}` placeholders.
26
27## Notes
28
29- Logs are persisted in neutral format (no rendered text) for future web UI/remote export.
30- Locale fallback is normalized; env vars (`WEBETTE_LANG`/`LANG`) are only a fallback if the tool config does not set `logging.locale`.