For the complete documentation index, see llms.txt. This page is also available as Markdown.

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.

log() and error() are synchronous, fire-and-forget calls that return void. They never reject, so there is nothing to .catch(). The host deliberately swallows any transport errors. This is unlike most other SDK methods, which return promises. See Error Handling for the methods that do need a .catch().

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/log level.

  • RundotGameAPI.error(...) emits at the error level.

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 Error instance becomes name: message.

  • A plain object is JSON.stringify'd. Objects that cannot be serialized (for example one with a circular reference) fall back to String(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

Method
Returns
Description

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 and log() for everything else; those are your only two levels.

  • Keep human-readable messages first, then pass context objects or Error instances 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.recordCustomEvent rather than the log message string.

  • Include relevant context (user ID, level, game state) so logs are useful when debugging production issues.

Last updated