Repository navigation
Commit 4bfc1dd
Roja Reddy Sareddy
fix(core): gate import-time root logger config behind opt-in
Addresses review feedback: get_textual_rich_logger() still called
logging.basicConfig(level=INFO, handlers=[RichHandler(...)]) at import,
which runs on a plain "import sagemaker.core" (via the module-level
loggers in utils.py, resources.py, and intelligent_defaults_helper.py).
That installed a RichHandler on the root logger and forced the root level
to INFO for the whole process, defeating the goal of not touching global
logging state on import.
Gate the basicConfig/RichHandler behind is_rich_logging_enabled() (the
same opt-in as the console/traceback). When not opted in,
get_textual_rich_logger() just returns logging.getLogger(name) without
configuring handlers or levels. Add tests asserting basicConfig is not
called on the opt-out path and is called when opted in.
Verified in a fresh process: default "import sagemaker.core" leaves the
root logger level and handlers unchanged and sys.excepthook as the stdlib
default.
Relates-to #5179
Relates-to #55611 parent eca6c70 commit 4bfc1dd
2 files changed
Lines changed: 34 additions & 8 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
194 | 194 | | |
195 | 195 | | |
196 | 196 | | |
197 | | - | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
198 | 204 | | |
199 | 205 | | |
200 | 206 | | |
201 | | - | |
| 207 | + | |
202 | 208 | | |
203 | 209 | | |
204 | 210 | | |
205 | 211 | | |
206 | | - | |
| 212 | + | |
207 | 213 | | |
208 | 214 | | |
209 | | - | |
210 | | - | |
211 | | - | |
212 | | - | |
213 | | - | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
214 | 219 | | |
215 | 220 | | |
216 | 221 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
91 | 91 | | |
92 | 92 | | |
93 | 93 | | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
0 commit comments