MCPcopy Create free account
hub / github.com/pytest-dev/pytest / _create_formatter

Method _create_formatter

src/_pytest/logging.py:590–606  ·  view source on GitHub ↗
(self, log_format, log_date_format, auto_indent)

Source from the content-addressed store, hash-verified

588 self.log_cli_handler.setFormatter(log_cli_formatter)
589
590 def _create_formatter(self, log_format, log_date_format, auto_indent):
591 # Color option doesn't exist if terminal plugin is disabled.
592 color = getattr(self._config.option, "color", "no")
593 if color != "no" and ColoredLevelFormatter.LEVELNAME_FMT_REGEX.search(
594 log_format
595 ):
596 formatter: logging.Formatter = ColoredLevelFormatter(
597 create_terminal_writer(self._config), log_format, log_date_format
598 )
599 else:
600 formatter = logging.Formatter(log_format, log_date_format)
601
602 formatter._style = PercentStyleMultiline(
603 formatter._style._fmt, auto_indent=auto_indent
604 )
605
606 return formatter
607
608 def set_log_path(self, fname: str) -> None:
609 """Set the filename parameter for Logging.FileHandler().

Callers 1

__init__Method · 0.95

Calls 3

create_terminal_writerFunction · 0.90

Tested by

no test coverage detected