class_docstr: Log formatter used in Tornado.
  
  Key features of this formatter are:
  
  * Color support when logging to a terminal that supports it.
  * Timestamps on every log line.
  * Robust against str/bytes encoding problems.
  
  This formatter is enabled automatically by
  `tornado.options.parse_command_line` or `tornado.options.parse_config_file`
  (unless ``--logging=none`` is used).
  
  Color support on Windows versions that do not support ANSI color codes is
  enabled by use of the colorama__ library. Applications that wish to use
  this must first initialize colorama with a call to ``colorama.init``.
  See the colorama documentation for details.
  
  __ https://pypi.python.org/pypi/colorama
  
  .. versionchanged:: 4.5
     Added support for ``colorama``. Changed the constructor
     signature to be compatible with `logging.config.dictConfig`.
class_docstr_tok: ["Log","formatter","used","in","Tornado",".","Key","features","of","this","formatter","are",":","*","Color","support","when","logging","to","a","terminal","that","supports","it",".","*","Timestamps","on","every","log","line",".","*","Robust","against","str\/bytes","encoding","problems",".","This","formatter","is","enabled","automatically","by","`","tornado.options.parse_command_line","`","or","`","tornado.options.parse_config_file","`","(","unless","``","--","logging=none","``","is","used",")",".","Color","support","on","Windows","versions","that","do","not","support","ANSI","color","codes","is","enabled","by","use","of","the","colorama__","library",".","Applications","that","wish","to","use","this","must","first","initialize","colorama","with","a","call","to","``","colorama.init","``",".","See","the","colorama","documentation","for","details",".","__","https",":","\/\/pypi.python.org\/pypi\/colorama","..","versionchanged",":",":","4.5","Added","support","for","``","colorama","``",".","Changed","the","constructor","signature","to","be","compatible","with","`","logging.config.dictConfig","`","."]
docstr: :arg bool color: Enables color support.
  :arg string fmt: Log message format.
    It will be applied to the attributes dict of log records. The
    text between ``%(color)s`` and ``%(end_color)s`` will be colored
    depending on the level if color support is on.
  :arg dict colors: color mappings from logging level to terminal color
    code
  :arg string datefmt: Datetime format.
    Used for formatting ``(asctime)`` placeholder in ``prefix_fmt``.
  
  .. versionchanged:: 3.2
  
     Added ``fmt`` and ``datefmt`` arguments.
docstr_tok: [":","arg","bool","color",":","Enables","color","support",".",":","arg","string","fmt",":","Log","message","format",".","It","will","be","applied","to","the","attributes","dict","of","log","records",".","The","text","between","``","%","(","color",")","s","``","and","``","%","(","end_color",")","s","``","will","be","colored","depending","on","the","level","if","color","support","is","on",".",":","arg","dict","colors",":","color","mappings","from","logging","level","to","terminal","color","code",":","arg","string","datefmt",":","Datetime","format",".","Used","for","formatting","``","(","asctime",")","``","placeholder","in","``","prefix_fmt","``",".","..","versionchanged",":",":","3.2","Added","``","fmt","``","and","``","datefmt","``","arguments","."]
code: def __init__(
      self,
      fmt=DEFAULT_FORMAT,
      datefmt=DEFAULT_DATE_FORMAT,
      style="%",
      color=True,
      colors=DEFAULT_COLORS,
  ):
      r"""
      :arg bool color: Enables color support.
      :arg string fmt: Log message format.
        It will be applied to the attributes dict of log records. The
        text between ``%(color)s`` and ``%(end_color)s`` will be colored
        depending on the level if color support is on.
      :arg dict colors: color mappings from logging level to terminal color
        code
      :arg string datefmt: Datetime format.
        Used for formatting ``(asctime)`` placeholder in ``prefix_fmt``.
  
      .. versionchanged:: 3.2
  
         Added ``fmt`` and ``datefmt`` arguments.
      """
      logging.Formatter.__init__(self, datefmt=datefmt)
      self._fmt = fmt
  
      self._colors = {}
      if color and _stderr_supports_color():
          if curses is not None:
              # The curses module has some str/bytes confusion in
              # python3.  Until version 3.2.3, most methods return
              # bytes, but only accept strings.  In addition, we want to
              # output these strings with the logging module, which
              # works with unicode strings.  The explicit calls to
              # unicode() below are harmless in python2 but will do the
              # right conversion in python 3.
              fg_color = (
                  curses.tigetstr("setaf")
                  or curses.tigetstr("setf")
                  or ""
              )
              if (3, 0) < sys.version_info < (3, 2, 3):
                  fg_color = unicode_type(fg_color, "ascii")
  
              for levelno, code in colors.items():
                  self._colors[levelno] = unicode_type(
                      curses.tparm(fg_color, code), "ascii"
                  )
              self._normal = unicode_type(
                  curses.tigetstr("sgr0"), "ascii"
              )
          else:
              # If curses is not present (currently we'll only get here for
              # colorama on windows), assume hard-coded ANSI color codes.
              for levelno, code in colors.items():
                  self._colors[levelno] = "\033[2;3%dm" % code
              self._normal = "\033[0m"
      else:
          self._normal = ""
  
file_path: catboost/contrib/python/tornado/tornado-4/tornado/log.py
imports: from __future__ import absolute_import, division, print_function
  import logging
  import logging.handlers
  import sys
  from tornado.escape import _unicode
  from tornado.util import unicode_type, basestring_type
label_desc: Use image node_id 1 to create a new LogFormatter object from inherited base classes: logging with example: obj = LogFormatter(fmt, datefmt, style, color, colors)