-
Notifications
You must be signed in to change notification settings - Fork 0
Examples LoggingFormat
Truong Giang Vu edited this page Feb 14, 2026
·
2 revisions
Demo: Test log formatting, colors, and structured output
Script: logging_format_script.py
Time: 1-2 minutes
- Log level detection via keywords
- Syntax highlighting for different data types
- JSON pretty-printing
- Exception stack traces with formatting
print("[INFO] This should be Information level")
print("[WARN] This should be Warning level")
print("[ERROR] This should be Error level")
print("[FATAL] This should be Critical level")Output: Each line appears in Trace Panel with appropriate color.
print("Operation completed successfully") # β Info (contains "completed")
print("Warning: Memory usage is high") # β Warning (contains "warning")
print("Error occurred during processing") # β Error (contains "error")Output: Automatic color coding based on detected keywords.
import json
data = {
"project": "Office Building",
"walls": 127,
"floors": 8,
"families": ["Walls", "Doors", "Windows"]
}
print(json.dumps(data, indent=2))Output in Trace Panel:
{
"project": "Office Building",
"walls": 127,
"floors": 8,
"families": [
"Walls",
"Doors",
"Windows"
]
}- Keys in purple
- Strings in yellow
- Numbers in cyan
- Proper indentation preserved
try:
result = 10 / 0
except Exception as e:
print(f"ERROR: {e}")
import traceback
traceback.print_exc()Output:
ERROR: division by zero
Traceback (most recent call last):
File "logging_format_script.py", line 85, in test_exceptions
result = 10 / 0
ZeroDivisionError: division by zero
- Stack trace with syntax highlighting
- File paths clickable (if configured)
- Line numbers visible
-
Load folder:
source/RevitDevTool.PythonDemo/commands/ -
Execute
logging_format_script.py - Watch Trace Panel for colored output
- Observe different log levels and formatting
Full source: logging_format_script.py
-
Logging performance β
logging_batch_script.py -
Data analysis β
data_analysis_script.py