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.
from witwin import Console
# Basic logging
Console . log ( "Processing started" )
Console . warn ( "Low memory warning" )
Console . error ( "Failed to load data" )
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 Description 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
Type Description Color Info/Log General output White/Black Warning Warning messages Yellow Error Error messages Red
[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
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" )
# Standard print with tags (auto-captured)
print ( "[Camera] Starting render..." )
print ( f "[Camera] Image size: { width } x { height } " )
print ( "[Camera] Render complete" )
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
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
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
Control Action Clear Empty the console Pause Stop auto-scroll Copy Copy selected text Export Save log to file
Action Description Click Select single line Shift+Click Select range Ctrl+A Select all Ctrl+C Copy to clipboard
{
"type" : "console_output" ,
"level" : "log" ,
"message" : "Processing complete" ,
"timestamp" : "2024-01-20T14:23:01Z" ,
"source" : "Camera"
}
{ "type" : "get_console_history" }
{ "type" : "execute_console_command" , "command" : "/stats" }
{ "type" : "clear_console" }
{ "type" : "get_console_commands" }
Line Limit : Maximum 1000 lines (configurable)
Virtual Scrolling : Only render visible lines
Batch Updates : Group rapid messages
Circular Buffer : Old messages automatically removed
The console uses a circular buffer to manage memory:
Max messages: 1000 (default)
New messages → Push to buffer
Buffer full → Remove oldest messages
Timestamps : Time displayed for each message
Color Coding : Messages colored by type
Monospace Font : Code-friendly display
Word Wrap : Optional for long lines