Lynxer

Documentation

debug

Assertions, type inspection, structured logging, timers and process metrics.

Backend: native + pure — stdlib/debug.so (stdlib/debug.cpp) provides timers, timestamps, environment and memory; the assertions and logging helpers are written in Lynxer in stdlib/debug.lynx. Import: import("debug") → global.debug.*

Assertions

FunctionSignatureNotes
assert(bool cond, str msg)Fails with msg when cond is false
assertEq(str a, str b, str msg)Fails unless the strings are equal
assertNotEq(str a, str b, str msg)Fails when the strings are equal
assertGt(float a, float b, str msg)Fails unless a > b
assertLt(float a, float b, str msg)Fails unless a < b
assertContains(str haystack, str needle, str msg)Fails unless needle is a substring

Inspection

FunctionSignatureNotes
typeOf(any val) -> strint, float, str, bool, list, tuple or null
dump(any val)Prints [debug.dump] type=T value=V
inspect(any val) -> strJSON {"type": ..., "value": ...}
pp(any val)Indented JSON for lists, plain text otherwise

typeOf maps the interpreter's none to null. dump/pp use strOf rendering, so strings are not quoted.

Logging

log(str level, str msg), info(str msg), warn(str msg), error(str msg), debug(str msg) — each prints [LEVEL HH:MM:SS] message. The timestamp makes these unsuitable for exact-output tests.

Timers

FunctionSignatureNotes
startTimer(str label)Records a monotonic start time
stopTimer(str label) -> floatMilliseconds since start, removes the timer; -1.0 if unknown
elapsed(str label) -> floatMilliseconds without stopping; -1.0 if unknown
clock() -> floatMonotonic milliseconds since an arbitrary origin

Environment and memory

FunctionSignatureNotes
envGet(str key) -> strValue, or ""
envAll() -> strAll variables as a JSON object
getMemory() -> floatPeak RSS in megabytes (getrusage), or -1.0

Crash diagnostics

FunctionSignatureNotes
crashLogPath() -> str%LOCALAPPDATA%\Lynxer\crash.log on Windows; $XDG_STATE_HOME/lynxer/crash.log (or ~/.local/state/lynxer/crash.log) elsewhere
recordCrash(str message) -> boolAppends a timestamped trace to the crash log

Set LYNXER_CRASH_LOG to override the path, which also makes the diagnostics testable without touching the user's state directory.

Example

global setup(){ import("debug"); }

global main(){
    global.debug.assertEq(global.debug.typeOf(1), "int", "int type");
    global.debug.startTimer("work");
    println(global.debug.stopTimer("work") >= 0.0);
    println(global.debug.inspect("text"));
}

See also

Deterministic log tests

The native backend accepts LYNXER_DEBUG_TEST_EPOCH (Unix seconds, rendered in UTC) and LYNXER_DEBUG_TEST_CLOCK_MS (milliseconds) as test clock overrides. They are unset by default; production logging and timers use the system wall clock and monotonic clock respectively.