RFDT Solver and WiTwin Simulator are undergoing internal testing as we prepare for public release. The functions are limited. Sign up to receive updates.

Console

Real-time output console for backend Python messages, errors, and system logs

Overview#

The Console panel displays backend Python print statements, errors, warnings, and system messages in real-time. It provides essential debug output and backend monitoring via WebSocket-based streaming with minimal latency.

Quick Start#

from witwin import Console
 
# Basic logging
Console.log("Processing started")
Console.warn("Low memory warning")
Console.error("Failed to load data")

API Reference#

from witwin import Console
 
# Log methods
Console.log(message, source=None, level="log")
Console.warn(message)
Console.error(message)
 
# Command registration
Console.register_command(name, handler, description=None)

Method Details#

MethodDescription
Console.log(message, source, level)Log a message with optional source tag and level
Console.warn(message)Log a warning message (yellow)
Console.error(message)Log an error message (red)
Console.register_command(name, handler, description)Register a custom console command

Message Types#

TypeDescriptionColor
Info/LogGeneral outputWhite/Black
WarningWarning messagesYellow
ErrorError messagesRed

Message Format#

[HH:MM:SS] [Source] Message content
[14:23:01] [Server] Client connected
[14:23:02] [Camera] Rendering view...
[14:23:03] [Error] Failed to load mesh

Usage Examples#

Basic Logging#

from witwin import Console
 
# Simple messages
Console.log("Processing complete")
Console.warn("Memory usage high: 85%")
Console.error("Failed to connect to database")
 
# With source tag
Console.log("Rendering started", source="Camera")
Console.log("Frame rendered in 16ms", source="Camera")

Tagged Output with Print#

# Standard print with tags (auto-captured)
print("[Camera] Starting render...")
print(f"[Camera] Image size: {width}x{height}")
print("[Camera] Render complete")

Error Handling#

from witwin import Console
import traceback
 
try:
    result = process_data()
except Exception as e:
    Console.error(f"Processing failed: {e}")
    traceback.print_exc()  # Full stack trace

Custom Commands#

from witwin import Console
 
def clear_cache():
    # Clear cache logic
    return "Cache cleared successfully"
 
def get_stats():
    return f"Objects: {obj_count}, Memory: {mem_mb}MB"
 
# Register commands
Console.register_command("clear_cache", clear_cache, "Clear the object cache")
Console.register_command("stats", get_stats, "Show current statistics")
 
# Users can then type in console:
# /clear_cache
# /stats

Interactive Features#

Filtering#

  • Search Box: Filter messages by text
  • Type Filter: Show/hide message types (info, warning, error)
  • Regex Support: Pattern matching for advanced filtering
  • Clear Filter: Reset to show all messages

Controls#

ControlAction
ClearEmpty the console
PauseStop auto-scroll
CopyCopy selected text
ExportSave log to file

Selection#

ActionDescription
ClickSelect single line
Shift+ClickSelect range
Ctrl+ASelect all
Ctrl+CCopy to clipboard

WebSocket Protocol#

Message Format#

{
  "type": "console_output",
  "level": "log",
  "message": "Processing complete",
  "timestamp": "2024-01-20T14:23:01Z",
  "source": "Camera"
}

Supported Message Types#

{ "type": "get_console_history" }
{ "type": "execute_console_command", "command": "/stats" }
{ "type": "clear_console" }
{ "type": "get_console_commands" }

Performance#

Optimization Features#

  • Line Limit: Maximum 1000 lines (configurable)
  • Virtual Scrolling: Only render visible lines
  • Batch Updates: Group rapid messages
  • Circular Buffer: Old messages automatically removed

Memory Management#

The console uses a circular buffer to manage memory:

Max messages: 1000 (default)
New messages → Push to buffer
Buffer full → Remove oldest messages

Visual Features#

  • Timestamps: Time displayed for each message
  • Color Coding: Messages colored by type
  • Monospace Font: Code-friendly display
  • Word Wrap: Optional for long lines