Skip to content

Commit f4fb4f6

Browse files
committed
feat(changelog): update for version 2.0.0
- Dropped support for Revit 2021; minimum version is now Revit 2022 - Removed SQLite and CLEF log formats; JSON is now the preferred format - Added WPF Trace Listener for capturing binding errors - Introduced automatic log level detection with customizable keywords - Enabled pretty JSON output for complex objects in logs - Added Revit context enrichers for log entries - Implemented a new single-page settings UI - Added live geometry count badge for real-time visualization feedback - Enhanced Python stack trace support for better debugging - Implemented auto-clean for log files based on rolling intervals - Updated log file naming to include process ID for easier identification
1 parent 3d5ed65 commit f4fb4f6

File tree

2 files changed

+230
-3
lines changed

2 files changed

+230
-3
lines changed

Changelog.md

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,76 @@
1+
# 2.0.0
2+
3+
## Breaking Changes
4+
5+
- **Dropped Revit 2021 Support** - Minimum supported version is now Revit 2022
6+
- **Removed SQLite Log Format** - SQLite (.db) logging format has been removed. Use JSON or CLEF formats for structured logging
7+
- **Removed CLEF Log Format** - CLEF (.clef) format has been removed. Use JSON format for Seq integration
8+
9+
## Added
10+
11+
- **WPF Trace Listener**
12+
- Capture WPF binding errors and trace output directly in the log panel
13+
- Configurable WPF trace level (Off, Error, Warning, Information, Verbose)
14+
- Helps debug XAML binding issues without external tools
15+
16+
- **Filter Keywords for Log Level Detection**
17+
- Automatic log level detection based on message content
18+
- Customizable keywords for each log level (Information, Warning, Error, Critical)
19+
- Default keywords: `info,success,completed` for Info, `warning,warn,caution` for Warning, etc.
20+
- Supports prefix detection: `[INFO]`, `[WARN]`, `[ERROR]`, `[FATAL]`, `[DEBUG]`
21+
22+
- **Pretty JSON Output**
23+
- Enable formatted JSON output for complex objects in trace logs
24+
- Objects logged via `Trace.WriteLine(object)` are automatically serialized
25+
- Configurable via settings UI
26+
27+
- **Revit Enrichers**
28+
- Add Revit context to every log entry automatically
29+
- Available enrichers: Revit Version, Document Title, Document Path, Model Path, Addin ID
30+
- Configurable via settings UI
31+
32+
- **New Single-Page Settings UI**
33+
- All settings now accessible in a single integrated panel
34+
- No more separate settings window - everything in the dockable panel
35+
- Cleaner, more intuitive configuration experience
36+
37+
- **Live Geometry Count Badge**
38+
- Real-time badge showing count of geometry objects currently visualized
39+
- Visual feedback for geometry pool status
40+
- Helps track visualization state at a glance
41+
42+
- **Python Stack Trace Support**
43+
- Enhanced logging for Python/pyRevit scripts with full traceback
44+
- `PyTrace.Write(message, traceback)` bridge for Python integration
45+
- Respects stack trace depth settings
46+
- Helper script: [`source/RevitDevTool/Logging/Python/trace.py`](source/RevitDevTool/Logging/Python/trace.py)
47+
48+
- **Auto-Clean Log Files**
49+
- Automatically clean old log files based on rolling interval
50+
- Prevents log folder from growing indefinitely
51+
52+
- **Process ID in Log Files**
53+
- Log file names now include process ID for multi-instance scenarios
54+
- Easier identification of logs from different Revit sessions
55+
56+
## Changed
57+
58+
- **Logging Architecture Refactored**
59+
- Complete reorganization of logging infrastructure
60+
- Improved separation of concerns between trace listener and logger adapter
61+
- Better extensibility for future logging backends
62+
63+
- **UI Enhancements**
64+
- Improved settings panel layout and organization
65+
- Better visual feedback for pending changes
66+
- Enhanced theme consistency
67+
68+
## Fixed
69+
70+
- Stack trace now properly included in UI output
71+
- Settings reset functionality improved
72+
- geometry rendering ratio calculations
73+
174
# 1.4.0
275

376
## Added

README.md

Lines changed: 157 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ Autodesk Revit plugin project organized into multiple solution files that target
1818
* [Features](#features)
1919
* [How to Use](#how-to-use)
2020
* [For Python/IronPython Users](#for-pythonironpython-users)
21+
* [Colored Log Output with Keywords](#colored-log-output-with-keywords)
22+
* [Pretty JSON Output](#pretty-json-output)
2123
* [🎨 Trace Geometry - Beautiful 3D Visualization](#-trace-geometry---beautiful-3d-visualization)
2224
* [Supported Geometry Types](#supported-geometry-types)
2325
* [Key Features](#key-features)
@@ -27,6 +29,12 @@ Autodesk Revit plugin project organized into multiple solution files that target
2729
* [Example 1: Debugging Element Geometry](#example-1-debugging-element-geometry)
2830
* [Example 2: Visualizing Analysis Results](#example-2-visualizing-analysis-results)
2931
* [Example 3: Python Script Integration](#example-3-python-script-integration)
32+
* [🐍 Python Stack Trace with pyRevit](#-python-stack-trace-with-pyrevit)
33+
* [Setup](#setup)
34+
* [Usage](#usage-1)
35+
* [Output Example](#output-example)
36+
* [How It Works](#how-it-works)
37+
* [Configuration](#configuration)
3038
* [🎛️ User Interface Features](#-user-interface-features)
3139
* [🔧 Language Support](#-language-support)
3240
* [💡 Best Practices](#-best-practices)
@@ -128,6 +136,70 @@ print("This will appear in the trace log")
128136
Console.WriteLine("Direct console output from Python")
129137
```
130138

139+
#### Colored Log Output with Keywords
140+
141+
RevitDevTool automatically detects log levels from message content using configurable keywords. This enables colored output even when using `Trace.WriteLine()`:
142+
143+
**Prefix Detection (Highest Priority)**
144+
```csharp
145+
Trace.WriteLine("[INFO] This will be Information level (blue)");
146+
Trace.WriteLine("[WARN] This will be Warning level (yellow)");
147+
Trace.WriteLine("[ERROR] This will be Error level (red)");
148+
Trace.WriteLine("[FATAL] This will be Critical level (dark red)");
149+
Trace.WriteLine("[DEBUG] This will be Debug level (gray)");
150+
```
151+
152+
**Keyword Detection (Fallback)**
153+
```csharp
154+
Trace.WriteLine("Operation completed successfully"); // "completed" → Info
155+
Trace.WriteLine("Warning: Memory usage is high"); // "warning" → Warning
156+
Trace.WriteLine("Error occurred during processing"); // "error" → Error
157+
Trace.WriteLine("Fatal crash detected in system"); // "fatal" → Critical
158+
```
159+
160+
**Default Keywords (Customizable in Settings)**
161+
| Level | Default Keywords |
162+
|-------|-----------------|
163+
| Information | `info`, `success`, `completed` |
164+
| Warning | `warning`, `warn`, `caution` |
165+
| Error | `error`, `failed`, `exception` |
166+
| Critical | `fatal`, `critical`, `crash` |
167+
168+
#### Pretty JSON Output
169+
170+
Enable **Pretty JSON** in settings to automatically format complex objects as indented JSON:
171+
172+
```csharp
173+
// Log complex objects with automatic JSON formatting
174+
var auditLog = new
175+
{
176+
EventId = Guid.NewGuid(),
177+
Timestamp = DateTime.UtcNow,
178+
User = new { Id = "user456", Role = "Administrator" },
179+
Changes = new[]
180+
{
181+
new { Property = "MaxConnections", OldValue = 100, NewValue = 200 }
182+
}
183+
};
184+
185+
Trace.WriteLine(auditLog); // Outputs formatted JSON when Pretty JSON is enabled
186+
```
187+
188+
**Output with Pretty JSON enabled:**
189+
```json
190+
{
191+
"EventId": "a1b2c3d4-...",
192+
"Timestamp": "2026-01-18T10:30:00Z",
193+
"User": {
194+
"Id": "user456",
195+
"Role": "Administrator"
196+
},
197+
"Changes": [
198+
{ "Property": "MaxConnections", "OldValue": 100, "NewValue": 200 }
199+
]
200+
}
201+
```
202+
131203
### 🎨 Trace Geometry - Beautiful 3D Visualization
132204

133205
The Geometry Visualization system allows you to display transient geometry directly in the Revit 3D view, similar to Dynamo's preview functionality but integrated into your development workflow.
@@ -298,11 +370,95 @@ selected_walls = [doc.GetElement(id) for id in uidoc.Selection.GetElementIds()]
298370
analyze_walls(selected_walls)
299371
```
300372

373+
### 🐍 Python Stack Trace with pyRevit
374+
375+
RevitDevTool provides enhanced Python logging with full stack trace support for pyRevit scripts. This feature captures the Python call stack and displays it alongside your log messages.
376+
377+
> **Note**: This feature currently supports **pyRevit** only. Support for RevitPythonShell and standalone IronPython can be added by modifying the `trace.py` helper.
378+
379+
#### Setup
380+
381+
1. Copy [`trace.py`](source/RevitDevTool/Logging/Python/trace.py) from RevitDevTool to your pyRevit extension folder or script directory
382+
2. Import the `trace` function in your script
383+
384+
#### Usage
385+
386+
```python
387+
# trace.py should be in the same folder or in your pyRevit lib folder
388+
from trace import trace
389+
390+
def process_elements(elements):
391+
trace("Starting element processing")
392+
393+
for element in elements:
394+
trace("Processing element: {}".format(element.Id))
395+
# Your processing logic here
396+
397+
trace("Completed processing {} elements".format(len(elements)))
398+
399+
def main():
400+
trace("Script started")
401+
elements = get_selected_elements()
402+
process_elements(elements)
403+
trace("Script finished")
404+
405+
main()
406+
```
407+
408+
#### Output Example
409+
410+
When stack trace is enabled in settings, the output includes the Python call chain:
411+
412+
```
413+
Script started
414+
Traceback (Last call first):
415+
File "C:\Users\...\MyScript.pushbutton\script.py", in main
416+
File "C:\Users\...\MyScript.pushbutton\script.py", in <module>
417+
```
418+
419+
#### How It Works
420+
421+
The `trace.py` helper:
422+
1. Captures the Python traceback using `traceback.extract_stack()`
423+
2. Formats the stack frames with file paths and function names
424+
3. Sends the message and traceback to `PyTrace.Write()` if RevitDevTool is loaded
425+
4. Falls back to standard `Trace.Write()` if RevitDevTool is not available
426+
427+
```python
428+
# trace.py internals (simplified)
429+
import traceback
430+
from pyrevit.compat import NETCORE
431+
from pyrevit import EXEC_PARAMS
432+
433+
def trace(message):
434+
stack = traceback.extract_stack()
435+
clean_stack = stack[:-1] # Remove this function call
436+
clean_stack.reverse() # Most recent call first
437+
438+
formatted_lines = []
439+
for frame in clean_stack:
440+
file_path = getattr(frame, 'filename', frame[0])
441+
func_name = getattr(frame, 'name', frame[2])
442+
if file_path == "<string>":
443+
file_path = EXEC_PARAMS.command_path
444+
formatted_lines.append(' File "{}", in {}'.format(file_path, func_name))
445+
446+
stack_str = "\n".join(formatted_lines)
447+
448+
# PyTrace.Write respects IncludeStackTrace and StackTraceDepth settings
449+
PyTrace.Write(message, stack_str)
450+
```
451+
452+
#### Configuration
453+
454+
Stack trace behavior is controlled by settings:
455+
- **Include Stack Trace**: Enable/disable stack trace in output
456+
- **Stack Trace Depth**: Number of stack frames to display (default: 3)
457+
301458
### 🎛️ User Interface Features
302459

303460
- **Dockable Panel**: Integrated seamlessly with Revit's interface
304461
- **Responsive Design**: Works with Revit's light and dark themes (2024+)
305-
- **Resizable**: Minimum 300x400 pixels, can be resized as needed
306462
- **Keyboard Shortcuts**: Standard copy/paste functionality in the log view
307463
- **Auto-scroll**: Automatically scrolls to show new log entries
308464
- **Log Level Filtering**: Real-time filtering of log messages
@@ -312,9 +468,7 @@ analyze_walls(selected_walls)
312468
RevitDevTool works with multiple programming languages and scripting environments:
313469

314470
- **C#** - Full support through .NET Trace API
315-
- **VB.NET** - Full support through .NET Trace API
316471
- **Python/IronPython** - Full support via pyRevit, RevitPythonShell, or IronPython scripts
317-
- **F#** - Support through .NET interop
318472
- **Any .NET Language** - Works with any language that can access System.Diagnostics.Trace
319473

320474
### 💡 Best Practices

0 commit comments

Comments
 (0)