Home Contents | # debug.printk | Debug | Core4 Lua Commands

## SYNOPSIS

1. debug.printk(val[, ...])
2. debug.writek(val[, ...])

## DESCRIPTION

Functions for writing debug messages into the kernel system log. If the debug jumper was active during startup all messages printed to the log will appear on ttyS0 with 115200bps, 8N1. Output is completely unbuffered and interrupts are off during output. While this makes sure that any event that leads to a crash is reported, this also slows the system down considerably when used in excess.

It is recommended to use these function for hard crash debugging only. Remove every instance of it from production code before shipping.

The debug.printk works exactly the same way as the generic Lua print command, separating values with tabs and adding a final newline.

The debug.writek simply concatenates all passed values in string context and does not add any other data.

## BUGS

System can get very slow when used excessively.

## Notes

Regardless of the state of the debug jumper, the kernel log always writes the data into a circular buffer. The buffer can be displayed with the following example:

> > >
file = rawio.open("/dev/klog", rawio.rdonly | rawio.ndelay) for ln in file:lines() do print(ln) end file:close()

You cannot use lua's io library, as /dev/klog never reports EOF.