Standard Library: System, Process & Logging
Host process APIs are globals (and process / os / terminal object aliases). Prefer structured logging for services.
Structured logging (slog)
JSON-line logs for backends. Prefer these over print / console.log in production code. print still exists for scripts and examples.
slogInfo("ready", { service: "kyna" });
slogWarn("slow");
slogError("failed", { code: "KNET" });
# equivalent object form:
slog.info("ready", { service: "kyna" });
slog.warn("slow");
slog.error("failed", { code: "KNET" });
| Function | Description |
|---|---|
slogInfo(message, fields?) | Info line |
slogWarn(message, fields?) | Warning line |
slogError(message, fields?) | Error line |
The optional second argument is a closed object of extra fields.
Environment
processEnv(name) and process.env(name) return str?: the value, or null if unset.
const port = processEnv("PORT");
print(if (port != null) port else "8080");
Process, OS, crypto
| Function | Description |
|---|---|
processRun(command) / process.run | Run a host command (trusted capability) |
os.name() / osName() | Operating system name |
os.architecture() | CPU architecture |
os.cwd() | Working directory |
terminal.interactive() | TTY check |
cryptoSha256(data) | Lowercase hex SHA-256 digest |
Host information
os and terminal are injected capabilities. Embedders can replace every host adapter for deterministic tests.