MCPcopy
hub / github.com/pallets/click / set_level

Method set_level

tests/test_context.py:462–479  ·  view source on GitHub ↗

Set the logger to DEBUG level.

(self, ctx: Context, param: Parameter, value: str)

Source from the content-addressed store, hash-verified

460 called.append(True)
461
462 def set_level(self, ctx: Context, param: Parameter, value: str) -> None:
463 """Set the logger to DEBUG level."""
464 # Keep the logger name around so we can reset it later when winding down
465 # the option.
466 self.logger_name = value
467
468 # Get the global logger object.
469 logger = logging.getLogger(self.logger_name)
470
471 # Check pre-conditions: new logger is not set, but inherits its level from
472 # default <root> logger. That's the exact same state we are expecting our
473 # logger to be in after being messed with by the CLI.
474 assert logger.level == logging.NOTSET
475 assert logger.getEffectiveLevel() == logging.WARNING
476
477 logger.setLevel(logging.DEBUG)
478 ctx.call_on_close(self.reset_loggers)
479 return value
480
481 def __init__(self, *args, **kwargs) -> None:
482 kwargs.setdefault("callback", self.set_level)

Callers

nothing calls this directly

Calls 1

call_on_closeMethod · 0.80

Tested by

no test coverage detected