feat(stdlib): add Log.* — levelled, structured logging (#15)
All checks were successful
docs / build-and-deploy (push) Successful in 2s
All checks were successful
docs / build-and-deploy (push) Successful in 2s
A Log.* namespace: five levels (trace/debug/info/warn/error), a runtime threshold, and structured key=value fields, so games get something better than scattered print calls and release builds can go quiet without touching call sites. - Log.trace/debug/info/warn/error(msg, [k, v]...) -> stderr, "[LEVEL] msg k=v" - Log.set_level(n) show only level >= n (0 = all default, 5 silences all) - Log.level() read the current threshold Fields accept strings, ints, and longs (numbers formatted automatically); the level tag is chosen at compile time so a filtered-out level costs only a comparison. Writes to stderr, never touching the simulation — no effect on determinism/replays. v1 is the console sink; rotating-file and in-engine overlay sinks are noted as follow-ups. - examples/library/logging.ludic: asserts the set_level/level threshold round-trip and that every level (with mixed-type fields) runs without faulting; the stderr gating itself was verified by hand (warn/error emit, lower levels suppressed). Wired into `x test` (now 53 passed). - docs: a new Log section + per-symbol pages; inventory and coverage pass. - seed regenerated; `x bootstrap-cfree` fixpoint holds. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
parent
a4f1494a04
commit
031b138f84
17 changed files with 11166 additions and 10404 deletions
27
docs/language/log/log-set_level.md
Normal file
27
docs/language/log/log-set_level.md
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
---
|
||||
id: log-set_level
|
||||
name: Log.set_level
|
||||
category: log
|
||||
kind: namespace-method
|
||||
tokens: Log.set_level
|
||||
sig: Log.set_level(n) -> void
|
||||
tip: Show only messages at level n or above (0 = all).
|
||||
order: 6
|
||||
ns: Log
|
||||
member: set_level
|
||||
---
|
||||
|
||||
Sets the logging threshold: only messages whose level is <code>n</code> or higher are written; everything below is silently dropped. The levels are <code>trace</code> 0, <code>debug</code> 1, <code>info</code> 2, <code>warn</code> 3, <code>error</code> 4, so <code>set_level(3)</code> shows only warnings and errors, and the default of <code>0</code> shows everything. Set it once at startup — low in development, high (3, or 5 to silence all) for release — and every call site adjusts automatically. Read the current value back with <a href="log-level"><code>Log.level</code></a>.
|
||||
|
||||
Parameters:
|
||||
- `n` — the minimum level to show (0–4; use 5 to silence every level)
|
||||
|
||||
```ludic
|
||||
program Quiet {
|
||||
entry {
|
||||
Log.set_level(3) # warnings and errors only
|
||||
Log.info("startup") # dropped
|
||||
Log.warn("low memory") # shown
|
||||
}
|
||||
}
|
||||
```
|
||||
Loading…
Add table
Add a link
Reference in a new issue