|
6 | 6 | import logging
|
7 | 7 | import uuid
|
8 | 8 |
|
| 9 | + |
| 10 | +logger = logging.getLogger(__name__) |
9 | 11 | try:
|
10 | 12 | import pymsalruntime # ImportError would be raised on unsupported platforms such as Windows 8
|
11 | 13 | # Its API description is available in site-packages/pymsalruntime/PyMsalRuntime.pyi
|
12 |
| -except ImportError: |
| 14 | + pymsalruntime.set_logging_callback(lambda message, level: { # New in pymsalruntime 0.5.0 |
| 15 | + pymsalruntime.LogLevel.TRACE: logger.debug, # Python has no TRACE level |
| 16 | + pymsalruntime.LogLevel.DEBUG: logger.debug, |
| 17 | + # Let broker's excess info, warning and error logs map into default DEBUG, for now |
| 18 | + #pymsalruntime.LogLevel.INFO: logger.info, |
| 19 | + #pymsalruntime.LogLevel.WARNING: logger.warning, |
| 20 | + #pymsalruntime.LogLevel.ERROR: logger.error, |
| 21 | + pymsalruntime.LogLevel.FATAL: logger.critical, |
| 22 | + }.get(level, logger.debug)(message)) |
| 23 | +except (ImportError, AttributeError): # AttributeError happens when a prior pymsalruntime uninstallation somehow leaved an empty folder behind |
13 | 24 | # PyMsalRuntime currently supports these Windows versions, listed in this MSFT internal link
|
14 | 25 | # https://github.com/AzureAD/microsoft-authentication-library-for-cpp/pull/2406/files
|
15 | 26 | raise ImportError( # TODO: Remove or adjust this line right before merging this PR
|
|
18 | 29 | # Other exceptions (possibly RuntimeError) would be raised if its initialization fails
|
19 | 30 |
|
20 | 31 |
|
21 |
| -logger = logging.getLogger(__name__) |
22 |
| -pymsalruntime.set_logging_callback(lambda message, level: { # New in pymsalruntime 0.5.0 |
23 |
| - pymsalruntime.LogLevel.TRACE: logger.debug, # Python has no TRACE level |
24 |
| - pymsalruntime.LogLevel.DEBUG: logger.debug, |
25 |
| - # Let broker's excess info, warning and error logs map into default DEBUG, for now |
26 |
| - #pymsalruntime.LogLevel.INFO: logger.info, |
27 |
| - #pymsalruntime.LogLevel.WARNING: logger.warning, |
28 |
| - #pymsalruntime.LogLevel.ERROR: logger.error, |
29 |
| - pymsalruntime.LogLevel.FATAL: logger.critical, |
30 |
| - }.get(level, logger.debug)(message)) |
31 |
| - |
32 |
| - |
33 | 32 | class RedirectUriError(ValueError):
|
34 | 33 | pass
|
35 | 34 |
|
|
0 commit comments