Skip to content

fix(loader): translate logging level to Python scale in EnvDictionary…#3207

Merged
jmcouffin merged 4 commits intodevelopfrom
tay0thman-fix-console-startup-3203
Mar 31, 2026
Merged

fix(loader): translate logging level to Python scale in EnvDictionary…#3207
jmcouffin merged 4 commits intodevelopfrom
tay0thman-fix-console-startup-3203

Conversation

@tay0thman
Copy link
Copy Markdown
Contributor

…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! 🎉

@devloai
Copy link
Copy Markdown
Contributor

devloai bot commented Mar 30, 2026

Unable to trigger custom agent "Code Reviewer". You have run out of credits 😔
Please upgrade your plan or buy additional credits from the subscription page.

@tay0thman
Copy link
Copy Markdown
Contributor Author

@jmcouffin , Tested on Revit 2023,2024 and 2026 (IP 2.7), I welcome you and Copilot's Review.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 in EnvDictionarySeeder to map pyRevit logging levels to Python logging levels.
  • Seed PYREVIT_LOGGINGLEVEL using the translated (Python-scale) value instead of the raw enum int.
  • Updates the checked-in pyRevitExtensionParser.dll binary in bin/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).

@tay0thman
Copy link
Copy Markdown
Contributor Author

Added new commit. 64611f2

@jmcouffin another run by copilot is appreciated.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 4 out of 20 changed files in this pull request and generated 1 comment.

@jmcouffin jmcouffin merged commit a919b7a into develop Mar 31, 2026
@jmcouffin jmcouffin deleted the tay0thman-fix-console-startup-3203 branch March 31, 2026 15:29
@jmcouffin jmcouffin added the Enhancement Enhancement request [class->Improved #{number}: {title}] label Mar 31, 2026
@github-actions
Copy link
Copy Markdown
Contributor

📦 New work-in-progress (wip) builds are available for 6.1.0.26090+1533-wip

@github-actions
Copy link
Copy Markdown
Contributor

📦 New work-in-progress (wip) builds are available for 6.1.0.26090+1536-wip

@github-actions
Copy link
Copy Markdown
Contributor

📦 New work-in-progress (wip) builds are available for 6.1.0.26090+1540-wip

@github-actions
Copy link
Copy Markdown
Contributor

📦 New work-in-progress (wip) builds are available for 6.1.0.26090+1540-wip

@github-actions
Copy link
Copy Markdown
Contributor

📦 New work-in-progress (wip) builds are available for 6.1.0.26090+1556-wip

@github-actions
Copy link
Copy Markdown
Contributor

📦 New public release are available for 6.2.0.26090+1754

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Enhancement Enhancement request [class->Improved #{number}: {title}]

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Latest WIP console window up on startup without verbose logging

3 participants