Every call to a ShuiHu log method —Documentation Index
Fetch the complete documentation index at: https://mintlify.com/michael-tiger-2010/wyvernjs/llms.txt
Use this file to discover all available pages before exploring further.
log, debug, warn, error, or dire — records a { statement, context, label, timestamp } entry in an internal array and routes output to console.log, console.warn, or console.error depending on severity. The timestamp is formatted as H:M;S.ms (hours, minutes, seconds, milliseconds separated by :, ;, and . respectively) using the local clock at the moment the log is recorded. Values are not zero-padded — for example, 9 hours, 7 minutes, 3 seconds, 50ms is recorded as 9:7;3.50.
Log methods
All log methods accept(statement, context?) where statement is the message string and context is any optional value you want to attach to the entry (an object, number, string, etc.).
| Method | Severity level | Console method |
|---|---|---|
sh.debug(s, ctx?) | 0 | console.log |
sh.log(s, ctx?) | 0 (alias for debug) | console.log |
sh.warn(s, ctx?) | 1 | console.warn |
sh.error(s, ctx?) | 2 | console.error |
sh.dire(s, ctx?) | 3 | console.error |
sh.outputLogs(label?, serialize?, lastAmount?)
Returns the filtered log history as an array of { msg, label, context } objects. Entries are filtered to those whose severity level is greater than or equal to the requested label.
label— minimum severity label to include. Defaults to'debug'(returns everything).serialize— iftrue(default), thecontextfield of each entry is JSON-stringified via a safe serializer that returns'[Unserializable object]'on failure.lastAmount— return only the last N entries. Defaults toInfinity(all matching entries).
sh.setUpdateFn(fn)
Registers a callback that fires every time a new log entry is recorded. The callback receives no arguments — call sh.outputLogs() inside it to retrieve the latest state. Useful for keeping a live log panel in sync:
setUpdateFn again replaces the previous one.
sh.clear()
Clears all entries from the in-memory log history. Does not affect the DOM or the registered update function.
DOM output (browser only)
sh.createLogHolder(parent?)
Creates a fixed-position div.logholder overlay anchored to the bottom-left of the screen — 20vw wide, full viewport height, with a semi-transparent black background. The element is appended to parent, which defaults to document.body.
sh.outputElementLogs(label?, lastAmount?)
Returns an array of div.log DOM elements, one per matching log entry. Each element is assigned the CSS classes log and l0–l3 based on severity level, and its text content is set to the log message plus a formatted context string. lastAmount defaults to 100.
This method calls DiWu’s .text() and .setClasses() extension methods on DOM elements internally.
Suggested CSS
Apply these styles to give the log overlay readable formatting with severity-level colour coding:l0 (debug) has no background, so debug entries blend into the overlay’s base background. l1–l3 use progressively more intense warning colours.
outputElementLogs calls DiWu’s .text() and .setClasses() methods on DOM elements. Make sure dw.init() has been called before using it, otherwise these methods will not exist on element instances and the call will throw.