Use ``DWAVE_LOG_LEVEL`` (name or value) and ``DWAVE_LOG_FORMAT`` ("json" for structured output) environment variables to configure logging.
(logger: logging.Logger)
| 234 | |
| 235 | |
| 236 | def configure_logging_from_env(logger: logging.Logger) -> bool: |
| 237 | """Use ``DWAVE_LOG_LEVEL`` (name or value) and ``DWAVE_LOG_FORMAT`` ("json" |
| 238 | for structured output) environment variables to configure logging. |
| 239 | """ |
| 240 | |
| 241 | log_level = os.getenv('DWAVE_LOG_LEVEL', os.getenv('dwave_log_level')) |
| 242 | log_format = os.getenv('DWAVE_LOG_FORMAT', os.getenv('dwave_log_format', '')) |
| 243 | |
| 244 | if not log_level: |
| 245 | return False |
| 246 | |
| 247 | configure_logging(logger, additive=False, |
| 248 | level=parse_loglevel(log_level), |
| 249 | structured_output=(log_format.strip().lower() == 'json')) |
| 250 | |
| 251 | return True |
| 252 | |
| 253 | |
| 254 | def pretty_argvalues(): |
no test coverage detected