API Reference /Console

API Reference

Console

Print messages, warnings and errors to the editor's console while you debug.

Messages show up in the console under the editor. Errors thrown by your code show up there too.

#log

Prints a message.

console.log(message: string): void

console.log("x = " + x.toString())
Console.Log(string message)

Console.Log($"x = {x:F1}");
print(*values)

print(f"x = {x:.1f}")

#warn

Prints a warning.

console.warn(message: string): void
Console.Warn(string message)
Not available in Python yet. Compare languages

Python has no separate warning level. Use print(), or print to sys.stderr to show the message as an error.

#error

Prints an error.

console.error(message: string): void
Console.Error(string message)
import sys
print("Something went wrong", file=sys.stderr)

#Debugging tips

  • Don't log every frame unless you need to. At 60 FPS the console fills fast. Log in events, or every N frames.
  • Draw debug info on the canvas instead. text()Canvas.Text()text() with screen.fps()Screen.FPSfps(), positions or state is often clearer than the console.
fill(255, 255, 255)
font("monospace", 12)
text("FPS " + Math.round(screen.fps()).toString(), 8, 8)
text("x " + x.toString(), 8, 24)
Canvas.Fill(255, 255, 255);
Canvas.Font("monospace", 12);
Canvas.Text($"FPS {Screen.FPS:F0}", 8, 8);
Canvas.Text($"x {x:F1}", 8, 24);
fill(255, 255, 255)
font("monospace", 12)
text(f"FPS {fps():.0f}", 8, 8)
text(f"x {x:.1f}", 8, 24)
Esc