fix(loader): translate logging level to Python scale in EnvDictionary…#3207
fix(loader): translate logging level to Python scale in EnvDictionary…#3207
Conversation
|
Unable to trigger custom agent "Code Reviewer". You have run out of credits 😔 |
|
@jmcouffin , Tested on Revit 2023,2024 and 2026 (IP 2.7), I welcome you and Copilot's Review. |
There was a problem hiding this comment.
Pull request overview
Fixes a startup logging-level mismatch between the C# loader’s PyRevitConfig.LoggingLevel (0/1/2) and Python’s logging levels (30/20/10), which was causing DEBUG output (and the ScriptConsole window) to appear on Revit startup even when the user configured “Quiet”.
Changes:
- Add a
TranslateLoggingLevel()helper inEnvDictionarySeederto map pyRevit logging levels to Pythonlogginglevels. - Seed
PYREVIT_LOGGINGLEVELusing the translated (Python-scale) value instead of the raw enum int. - Updates the checked-in
pyRevitExtensionParser.dllbinary inbin/netfx/engines/IPY342/.
Reviewed changes
Copilot reviewed 1 out of 17 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| dev/pyRevitLoader/pyRevitAssemblyBuilder/SessionManager/EnvDictionarySeeder.cs | Translates and seeds logging level in Python’s expected numeric scale to prevent unwanted console output on startup. |
| bin/netfx/engines/IPY342/pyRevitExtensionParser.dll | Binary artifact updated as part of the PR (needs traceability/reproducibility confirmation). |
dev/pyRevitLoader/pyRevitAssemblyBuilder/SessionManager/EnvDictionarySeeder.cs
Outdated
Show resolved
Hide resolved
|
Added new commit. 64611f2 @jmcouffin another run by copilot is appreciated. |
dev/pyRevitLoader/pyRevitAssemblyBuilder/SessionManager/EnvDictionarySeeder.cs
Show resolved
Hide resolved
|
📦 New work-in-progress (wip) builds are available for 6.1.0.26090+1533-wip |
|
📦 New work-in-progress (wip) builds are available for 6.1.0.26090+1536-wip |
|
📦 New work-in-progress (wip) builds are available for 6.1.0.26090+1540-wip |
|
📦 New work-in-progress (wip) builds are available for 6.1.0.26090+1540-wip |
|
📦 New work-in-progress (wip) builds are available for 6.1.0.26090+1556-wip |
|
📦 New public release are available for 6.2.0.26090+1754 |
…Seeder (#3203)
fix(loader): translate logging level to Python scale in EnvDictionarySeeder
Problem
The console window (ScriptConsole) appears on every Revit startup showing DEBUG-level messages, even when the user's logging level is set to Quiet (the default). This was introduced in commit 47a34c3 when EnvDictionarySeeder was added for #3108..
Root Cause
EnvDictionarySeeder.Seed() writes PYREVIT_LOGGINGLEVEL using PyRevitConfig.LoggingLevel, which returns a pyRevit enum (0=Quiet, 1=Verbose, 2=Debug). But the Python logger reads this value and compares it against Python logging module levels (10=DEBUG, 20=INFO, 30=WARNING).
When Quiet mode is active, the seeder writes 0. The Python logger evaluates record.levelno >= 0 — always True — so every DEBUG message passes through to ScriptIO, which calls output.Show(), making the console visible.
Fix
Add a ToPythonLoggingLevel() translation method that maps:
0 (Quiet) → 30 (logging.WARNING)
1 (Verbose) → 20 (logging.INFO)
2 (Debug) → 10 (logging.DEBUG
Checklist
Default (Quiet) → no console window flash on startup
Verbose mode → console shows INFO+ messages
Debug mode → console shows DEBUG+ messages
All pyRevit buttons still function after fix
Reload pyRevit → console behavior correct
Legacy loader path (new_loader=False) unaffected
Related Issues
If applicable, link the issues resolved by this pull request:
Thank you for contributing to pyRevit! 🎉