def __init__(self, color=True, fmt=DEFAULT_FORMAT, datefmt=DEFAULT_DATE_FORMAT,
colors=DEFAULT_COLORS, precision=3):
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.
"""
super().__init__()
self.default_time_format = datefmt
self.precision = precision
self.default_msec_format = ''
self._fmt = fmt
self._colors = {}
if color and _stderr_supports_color():
fg_color = (curses.tigetstr('setaf') or
curses.tigetstr('setf') or '')
for levelno, code in colors.items():
self._colors[levelno] = curses.tparm(fg_color, code).decode()
self._normal = curses.tigetstr('sgr0').decode()
else:
self._normal = ''
评论列表
文章目录