class_docstr: Attaches to the logging module and captures log messages for each test.
      
class_docstr_tok: ["Attaches","to","the","logging","module","and","captures","log","messages","for","each","test","."]
code: def _create_formatter(self, log_format, log_date_format):
      # color option doesn't exist if terminal plugin is disabled
      color = getattr(self._config.option, "color", "no")
      if (
          color != "no"
          and ColoredLevelFormatter.LEVELNAME_FMT_REGEX.search(
              log_format
          )
      ):
          formatter = ColoredLevelFormatter(
              create_terminal_writer(self._config),
              log_format,
              log_date_format,
          )
      else:
          formatter = logging.Formatter(log_format, log_date_format)
  
      if not six.PY2:
          formatter._style = PercentStyleMultiline(
              formatter._style._fmt
          )
      return formatter
  
imports: from __future__ import absolute_import
  from __future__ import division
  from __future__ import print_function
  import logging
  import re
  from contextlib import contextmanager
  import py
  import six
  import pytest
  from _pytest.compat import dummy_context_manager
  from _pytest.config import create_terminal_writer
  from _pytest.pathlib import Path
label_desc: Use image node_id 2 for calling the LoggingPlugin obj's underlying member method code with example usage: obj._create_formatter(log_format, log_date_format) and returns: formatter