Logging API
Stream logs to the RUN.world host for debugging and support. The logging API mirrors console.log/console.error semantics while tagging messages with your game instance.
Mobile Debugging: This API lets creators get logs from mobile devices where console access isn't available. Logs are collected and can be viewed through support tools for debugging production issues.
Quick Start
import RundotGameAPI from '@series-inc/rundot-game-sdk/api'
RundotGameAPI.log('Gameplay started', { level: currentLevel })
RundotGameAPI.error('Fatal error', error)Log levels
There are exactly two levels, picked by which method you call:
RundotGameAPI.log(...)emits at the debug/loglevel.RundotGameAPI.error(...)emits at theerrorlevel.
There is no warn level, and the second argument is not an options bag. Any extra arguments are stringified and appended to the message text (see below), so passing { level: 'warn' } does not change the level: the message still logs at the log level.
// Debug-level logging
RundotGameAPI.log('Player moved', {
position: { x: 100, y: 200 },
velocity: { x: 5, y: 0 },
})
// Error-level logging
RundotGameAPI.error('Failed to load asset', {
assetPath: 'images/boss.png',
error: error.message,
})Extra arguments
Both methods are variadic, like console.log and console.error. The first argument is the message string; every additional truthy argument is converted to a string and appended to the message:
An
Errorinstance becomesname: message.A plain object is
JSON.stringify'd. Objects that cannot be serialized (for example one with a circular reference) fall back toString(arg)and render as[object Object], not JSON.Anything else is coerced with
String(...).
Concatenation rules. The stringified extra args are joined to each other with a single space, then appended to the message with no separator. So the message runs directly into the first arg, while subsequent args are space-separated from one another:
Error handling
API Reference
log(message: string, ...args)
void
Debug-level logging. Extra args are stringified and appended to the message.
error(message: string, ...args)
void
Error-level logging. Extra args are stringified and appended to the message.
Best Practices
Use
error()for failures andlog()for everything else; those are your only two levels.Keep human-readable messages first, then pass context objects or
Errorinstances as extra args.Throttle debug-level logging in production to reduce noise and bandwidth.
For data you need to filter or aggregate on, use
RundotGameAPI.analytics.recordCustomEventrather than the log message string.Include relevant context (user ID, level, game state) so logs are useful when debugging production issues.
Last updated