@@ -45,21 +45,6 @@ internal static class EnvDictionarySeeder
4545 private const string KeyAutoUpdating = "PYREVIT_AUTOUPDATE" ;
4646 private const string KeyOutputStyleSheet = "PYREVIT_STYLESHEET" ;
4747
48- /// <summary>
49- /// Converts PyRevitConfig's logging level enum (0=Quiet, 1=Verbose, 2=Debug)
50- /// to Python's logging module level (30=WARNING, 20=INFO, 10=DEBUG).
51- /// See: pyrevitlib/pyrevit/coreutils/logger.py DEFAULT_LOGGING_LEVEL
52- /// </summary>
53- private static int TranslateLoggingLevel ( int pyrevitLevel )
54- {
55- switch ( pyrevitLevel )
56- {
57- case 2 : return 10 ; // Debug → logging.DEBUG
58- case 1 : return 20 ; // Verbose → logging.INFO
59- default : return 30 ; // Quiet → logging.WARNING (default)
60- }
61- }
62-
6348 /// <summary>
6449 /// Builds the session environment dictionary and stores it in the AppDomain via a reflection
6550 /// call to <c>EnvDictionary.Seed()</c> in the Runtime assembly.
@@ -85,7 +70,11 @@ public static void Seed(UIApplication uiApp, Assembly runtimeAssembly, string py
8570 [ KeyIPYVersion ] = ReadIPYVersion ( pyRevitRoot ) ,
8671 [ KeyCPYVersion ] = "3.12.3" , // Known default for the bundled CPython engine
8772
88- [ KeyLoggingLevel ] = TranslateLoggingLevel ( config . LoggingLevel ) ,
73+ // Fix for #3203: PyRevitConfig.LoggingLevel returns a pyRevit enum
74+ // (0=Quiet, 1=Verbose, 2=Debug) but the Python logger reads this
75+ // env var as a Python logging module level (10=DEBUG, 20=INFO, 30=WARNING).
76+ // Translate to avoid corrupting the Python logging threshold.
77+ [ KeyLoggingLevel ] = ToPythonLoggingLevel ( config . LoggingLevel ) ,
8978 [ KeyFileLogging ] = config . FileLogging ,
9079
9180 [ KeyTelemetryState ] = config . TelemetryState ,
@@ -118,6 +107,27 @@ public static void Seed(UIApplication uiApp, Assembly runtimeAssembly, string py
118107 seedMethod . Invoke ( null , new object [ ] { values } ) ;
119108 }
120109
110+ /// <summary>
111+ /// Converts PyRevitConfig's logging level enum (0=Quiet, 1=Verbose, 2=Debug)
112+ /// to Python's logging module level (30=WARNING, 20=INFO, 10=DEBUG).
113+ /// <para>
114+ /// Python's logger (pyrevitlib/pyrevit/coreutils/logger.py) reads PYREVIT_LOGGINGLEVEL
115+ /// and compares it directly: <c>record.levelno >= _curlevel</c>. The Python logging
116+ /// constants are DEBUG=10, INFO=20, WARNING=30. If we store 0 (pyRevit Quiet) the
117+ /// comparison <c>10 >= 0</c> is always true — every message passes, which forces the
118+ /// console window open.
119+ /// </para>
120+ /// </summary>
121+ internal static int ToPythonLoggingLevel ( int pyrevitLevel )
122+ {
123+ switch ( pyrevitLevel )
124+ {
125+ case 2 : return 10 ; // Debug → logging.DEBUG
126+ case 1 : return 20 ; // Verbose → logging.INFO
127+ default : return 30 ; // Quiet → logging.WARNING (Python default)
128+ }
129+ }
130+
121131 private static string ReadPyRevitVersion ( string pyRevitRoot )
122132 {
123133 if ( string . IsNullOrEmpty ( pyRevitRoot ) )
0 commit comments