class_docstr: Log formatter with level-specific formatting.
  
  Formatter class which optionally takes a dict of logging levels to
  format strings, allowing to customise the log records appearance for
  specific levels.
  
  
  Attributes:
          fmt: A dictionary mapping logging levels to format strings.
                  The ``*`` key identifies the default format string.
          datefmt: As per py:class:`logging.Formatter`
          style: As per py:class:`logging.Formatter`
  
  >>> import sys
  >>> handler = logging.StreamHandler(sys.stdout)
  >>> formatter = LevelFormatter(
  ...     fmt={
  ...         '*':     '[%(levelname)s] %(message)s',
  ...         'DEBUG': '%(name)s [%(levelname)s] %(message)s',
  ...         'INFO':  '%(message)s',
  ...     })
  >>> handler.setFormatter(formatter)
  >>> log = logging.getLogger('test')
  >>> log.setLevel(logging.DEBUG)
  >>> log.addHandler(handler)
  >>> log.debug('this uses a custom format string')
  test [DEBUG] this uses a custom format string
  >>> log.info('this also uses a custom format string')
  this also uses a custom format string
  >>> log.warning("this one uses the default format string")
  [WARNING] this one uses the default format string
code: def __init__(self, fmt=None, datefmt=None, style="%"):
      if style != "%":
          raise ValueError(
              "only '%' percent style is supported in both python 2 and 3"
          )
      if fmt is None:
          fmt = DEFAULT_FORMATS
      if isinstance(fmt, str):
          default_format = fmt
          custom_formats = {}
      elif isinstance(fmt, Mapping):
          custom_formats = dict(fmt)
          default_format = custom_formats.pop("*", None)
      else:
          raise TypeError(
              "fmt must be a str or a dict of str: %r" % fmt
          )
      super(LevelFormatter, self).__init__(default_format, datefmt)
      self.default_format = self._fmt
      self.custom_formats = {}
      for level, fmt in custom_formats.items():
          level = logging._checkLevel(level)
          self.custom_formats[level] = fmt
  
imports: import sys
  import logging
  import timeit
  from functools import wraps
  from collections.abc import Mapping, Callable
  import warnings
  from logging import PercentStyle
label_desc: Use image node_id 1 to create a new LevelFormatter object from inherited base classes: logging with example: obj = LevelFormatter(fmt, datefmt, style)