debugger
this module implements logging and debug widgets.
Types
log
interface log {message: string--
the message logged.
status: "success" | "warn" | "error"--
the status of the log.
time: number--
when the message was logged.
count: number--
the amount of times the same message was sent. a value of 1 means the message isn't repeated.
}represents a logged message.
Properties
iris
debugger.iris: irisa reference to the iris library, which implements immediate-mode ui. this is used for debugger windows.
see iris' documentation and api reference for more detail.
output
a stack of all messages logged, which is rendered in the output.
the maximum amount of logs that can be stored is determined by the MAX_LOGS constant.
by default, this is set to 200.
Functions
log
debugger.log(message: string,--
the message to log.
status: "success" | "warn" | "error"--
the status of the message
) → ()logs a message to the output. logs are categorized by status:
successwarnerror, although errors do not block execution
if the message is the same as the last message, the count is incremented instead of pushing a new log.
messages are automatically prefixed with the current time and status, and have richtext enabled.
add_debugger
debugger.add_debugger(callback: () → (),--
a callback which is called every frame to render the window.
priority: number--
the priority of the debugger widget.
) → ()adds a new window to the debugger. the callback is called to render the window by debugger.render().
start
debugger.start(validate: (() → boolean)?--
if specified, returns a boolean which determines if the debugger should be rendered.
) → ()starts the debugger.
this can only be called once. if you want to call it again, call debugger.cleanup() first.
the validate parameter is passed to the debugger.render() function.
render
debugger.render(validate: (() → boolean)?--
if specified, returns a boolean which determines if the debugger should be rendered.
) → ()renders the debugger and its widgets.
cleanup
debugger.cleanup() → ()cleans outputted logs and all debuggers.
this resets the started flag to false.
you must call this before calling debugger.start() more than one time.