class_docstr: Colorize the %(levelname)..s part of the log format passed to __init__.
class_docstr_tok: ["Colorize","the","%","(","levelname",")","..","s","part","of","the","log","format","passed","to","__init__","."]
code: def __init__(self, terminalwriter, *args, **kwargs):
      super(ColoredLevelFormatter, self).__init__(*args, **kwargs)
      if six.PY2:
          self._original_fmt = self._fmt
      else:
          self._original_fmt = self._style._fmt
      self._level_to_fmt_mapping = {}
  
      levelname_fmt_match = self.LEVELNAME_FMT_REGEX.search(self._fmt)
      if not levelname_fmt_match:
          return
      levelname_fmt = levelname_fmt_match.group()
  
      for level, color_opts in self.LOGLEVEL_COLOROPTS.items():
          formatted_levelname = levelname_fmt % {
              "levelname": logging.getLevelName(level)
          }
  
          # add ANSI escape sequences around the formatted levelname
          color_kwargs = {name: True for name in color_opts}
          colorized_formatted_levelname = terminalwriter.markup(
              formatted_levelname, **color_kwargs
          )
          self._level_to_fmt_mapping[
              level
          ] = self.LEVELNAME_FMT_REGEX.sub(
              colorized_formatted_levelname, self._fmt
          )
  
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 1 to create a new ColoredLevelFormatter object from inherited base classes: logging with example: obj = ColoredLevelFormatter(terminalwriter)