26 lines
No EOL
4 KiB
HTML
26 lines
No EOL
4 KiB
HTML
<!doctype html>
|
||
<html lang="en">
|
||
<head>
|
||
<meta charset="utf-8">
|
||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||
<title>Log — Ludic</title>
|
||
<meta name="description" content="Levelled, structured logging — the default way to answer "what is my game doing?" and "why did that break?", and a real step up from scattering print calls…">
|
||
<link rel="stylesheet" href="base.css">
|
||
<link rel="stylesheet" href="docs.css">
|
||
</head>
|
||
<body>
|
||
<header class="nav"><div class="wrap nav-in"><a class="brand" href="index.html"><span class="logo">L</span> Ludic</a><button class="nav-toggle" aria-label="Toggle menu" aria-expanded="false">☰</button><nav class="nav-links"><a href="index.html">Home</a><a href="api.html">API Reference</a><a class="nav-cta" href="https://git.workshopsoft.io/workshopsoft/ludic">Source ↗</a></nav></div></header>
|
||
<main class="wrap item">
|
||
<div class="crumbs"><a href="api.html">API Reference</a> <span>›</span> <span class="here">Log</span></div>
|
||
<div class="item-head"><span class="kind-badge kind-namespace">namespace</span><h1 id="top">Log</h1></div>
|
||
<p class="ns-blurb">Levelled, structured logging — the default way to answer "what is my game doing?" and "why did that break?", and a real step up from scattering <code>print</code> calls through your code. Each message carries a level, from <a href="log-trace"><code>trace</code></a> (most verbose) through <a href="log-debug"><code>debug</code></a>, <a href="log-info"><code>info</code></a>, and <a href="log-warn"><code>warn</code></a> to <a href="log-error"><code>error</code></a>, and a runtime threshold set with <a href="log-set_level"><code>Log.set_level</code></a> decides which ones actually appear — so a development build can be chatty and a release build quiet, without touching the call sites.
|
||
|
||
Messages go to standard error, kept separate from a program's real stdout, tagged with their level. Beyond the message you can pass **structured fields** as trailing key/value pairs — <code>Log.warn("missing texture", "path", p, "id", n)</code> prints <code>[WARN] missing texture path=... id=...</code> — cheap to write and easy to grep. Numeric values (int, long) are formatted for you; the level tag is chosen at compile time, so a filtered-out level costs only a threshold comparison at runtime.
|
||
|
||
Logging never touches the simulation — it writes to stderr and returns — so it has no effect on gameplay determinism or replays. This first version ships the console (stderr) sink; a rotating-file sink and an in-engine overlay sink are planned follow-ups.</p>
|
||
<div class="ns-methods"><a class="ns-method" href="log-trace.html"><code class="nm-sig">Log.trace(msg, [key, value]...) -> void</code><span class="nm-tip">Log at the trace level (0) — the most verbose.</span></a><a class="ns-method" href="log-debug.html"><code class="nm-sig">Log.debug(msg, [key, value]...) -> void</code><span class="nm-tip">Log at the debug level (1) — development detail.</span></a><a class="ns-method" href="log-info.html"><code class="nm-sig">Log.info(msg, [key, value]...) -> void</code><span class="nm-tip">Log at the info level (2) — normal operation.</span></a><a class="ns-method" href="log-warn.html"><code class="nm-sig">Log.warn(msg, [key, value]...) -> void</code><span class="nm-tip">Log at the warn level (3) — something looks wrong.</span></a><a class="ns-method" href="log-error.html"><code class="nm-sig">Log.error(msg, [key, value]...) -> void</code><span class="nm-tip">Log at the error level (4) — a failure.</span></a><a class="ns-method" href="log-set_level.html"><code class="nm-sig">Log.set_level(n) -> void</code><span class="nm-tip">Show only messages at level n or above (0 = all).</span></a><a class="ns-method" href="log-level.html"><code class="nm-sig">Log.level() -> int</code><span class="nm-tip">The current logging threshold.</span></a></div>
|
||
<a class="back" href="api.html">← All symbols</a>
|
||
</main>
|
||
<script src="ludic-highlight.js"></script>
|
||
<script>Ludic.installCards(); Ludic.flashTarget();</script>
|
||
</body></html> |