console
Write data, status, and diagnostic information from scripts to instrument logs to locate code and reading issues.
Output and view logs
log, info, warn, error, debug receive one or more values and write them to the same log system according to the corresponding level. You can click Logs in the upper right corner to view the editor preview; the custom instrument menu of the main dashboard provides DEBUG log entry.
For example, when recording a missing parameter, the parameter identifier, original value and related status should be output at the same time to know whether the problem occurs in the input or in subsequent calculations. Log output depends on whether the corresponding log capture is turned on.
Example: Checking Speed Readings
Select the speed in the instrument settings, and then output the reading and calculation results at the code location that needs to be checked. Continuous drawing will execute main() repeatedly, and the high-frequency output should be removed after locating the problem.
function main() {
const speed = $data.current.speed;
console.log('speed', speed);
if (speed?.value == null) console.warn('Speed unavailable');
return <Text>{speed?.value == null ? '—' : speed.value}</Text>;
}
Log levels and runtime errors
console.error() only writes an error level log and will not throw an exception or stop drawing. Runtime errors are reported separately by the runtime. Object logs are expanded in readable form and limit the length of a single output, so they are not suitable for exporting complete data.
Prioritize output of necessary fields to avoid printing the entire history window every frame. Excessive logging increases overhead and makes real errors difficult to find.
Method
log(...values: unknown[])voidWrite a general log message
info(...values: unknown[])voidWrite an informational log message
warn(...values: unknown[])voidWrite a warning log message
error(...values: unknown[])voidWrite an error log message
debug(...values: unknown[])voidWrite a debug log message