ludic/docs/language/log/log-debug.md
Orkuncakilkaya 031b138f84
All checks were successful
docs / build-and-deploy (push) Successful in 2s
feat(stdlib): add Log.* — levelled, structured logging (#15)
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>
2026-08-30 21:57:22 +03:00

27 lines
928 B
Markdown

---
id: log-debug
name: Log.debug
category: log
kind: namespace-method
tokens: Log.debug
sig: Log.debug(msg, [key, value]...) -> void
tip: Log at the debug level (1) — development detail.
order: 2
ns: Log
member: debug
---
Logs <code>msg</code> at the **debug** level (1) — development-time detail that is useful while building a feature but noise in a shipped game. It prints on stderr as <code>[DEBUG] msg</code> with any structured <code>key=value</code> fields, when the <a href="log-set_level"><code>Log.set_level</code></a> threshold is 1 or lower. Reach for it to trace state transitions, loaded assets, or the values feeding a calculation you are not yet sure of.
Parameters:
- `msg` — the message string
- `key, value...` — optional trailing pairs; values may be strings or numbers
```ludic
program Debug {
entry {
Log.set_level(1)
Log.debug("player state", "hp", 100, "phase", "combat")
}
}
```