当前位置: 首页>>代码示例>>Python>>正文


Python Formatter.__init__方法代码示例

本文整理汇总了Python中logging.Formatter.__init__方法的典型用法代码示例。如果您正苦于以下问题:Python Formatter.__init__方法的具体用法?Python Formatter.__init__怎么用?Python Formatter.__init__使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在logging.Formatter的用法示例。


在下文中一共展示了Formatter.__init__方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: __init__

# 需要导入模块: from logging import Formatter [as 别名]
# 或者: from logging.Formatter import __init__ [as 别名]
    def __init__(self, stream=None):
        """
        Construct this formatter.

        Provides colored output if the stream parameter is specified and is an acceptable TTY.
        We print hardwired escape sequences, which will probably break in some circumstances;
        for this unfortunate shortcoming, we apologize.
        """

        # select and construct format string
        import curses

        format = None

        if stream and hasattr(stream, "isatty") and stream.isatty():
            curses.setupterm()

            # FIXME do nice block formatting, increasing column sizes as necessary
            if curses.tigetnum("colors") > 2:
                format = "%s%%(asctime)s%s %%(message)s" % (
                    TTY_VerboseFormatter._NAME_COLOR,
                    TTY_VerboseFormatter._COLOR_END,
                )

        if format is None:
            format = "%(name)s - %(levelname)s - %(message)s"

        # initialize this formatter
        Formatter.__init__(self, format, TTY_VerboseFormatter._DATE_FORMAT)
开发者ID:bsilverthorn,项目名称:cargo,代码行数:31,代码来源:log.py

示例2: __init__

# 需要导入模块: from logging import Formatter [as 别名]
# 或者: from logging.Formatter import __init__ [as 别名]
    def __init__(self, coloured=False):
        fmt = "%(asctime)s  %(address)s  %(levelname)s: %(message)s"
        datefmt = "%Y-%m-%d %H:%M:%S"
        self.linefmt = "    "
        self._coloured = coloured

        Formatter.__init__(self, fmt, datefmt)
开发者ID:pazdera,项目名称:lnst,代码行数:9,代码来源:Logs.py

示例3: __init__

# 需要导入模块: from logging import Formatter [as 别名]
# 或者: from logging.Formatter import __init__ [as 别名]
 def __init__(self, pidlog=False):
     pidlog = "[%(process)s] " if pidlog else ""
     self._normal_fmt = ("%(asctime)s " + pidlog +
                         "[%(levelname)s %(name)s] %(message)s")
     self._context_fmt = ("%(asctime)s " + pidlog + "[%(levelname)s "
                          "%(name)s] [%(context)s] %(message)s")
     Formatter.__init__(self, self._normal_fmt)
开发者ID:alexanderfefelov,项目名称:nav,代码行数:9,代码来源:log.py

示例4: __init__

# 需要导入模块: from logging import Formatter [as 别名]
# 或者: from logging.Formatter import __init__ [as 别名]
    def __init__(self, prefix='', only_from=None):
        """
        .. todo::

            WRITEME
        """
        Formatter.__init__(self)
        self._info_fmt = prefix + "%(message)s"
        self._fmt = prefix + "%(levelname)s (%(name)s): %(message)s"
        self._only_from = only_from
开发者ID:JakeMick,项目名称:pylearn2,代码行数:12,代码来源:logger.py

示例5: __init__

# 需要导入模块: from logging import Formatter [as 别名]
# 或者: from logging.Formatter import __init__ [as 别名]
 def __init__(self, formatter_for_level=dict(), default=Formatter()):
     """
     Use the given formatter_for_level map of {level: formatter} to
     format messages. If for a given level, a formatter does not exist in
     the formatter_for_level dictionary, the default formatter specified
     by 'default' is used instead.
     """
     Formatter.__init__(self)
     self.formatter_for_level = formatter_for_level
     self.default = default
开发者ID:AdrienDebrie,项目名称:sequencer,代码行数:12,代码来源:tracer.py

示例6: __init__

# 需要导入模块: from logging import Formatter [as 别名]
# 或者: from logging.Formatter import __init__ [as 别名]
    def __init__(self, stream, *args, **kwds):
        Formatter.__init__(self, *args, **kwds)

        # Create a mapping of levels to format string which is prepared to
        # contain the escape sequences.
        term = TerminalController(stream)
        self.color_fmt = {}
        for levelno, colstr in self.colordef:
            slist = [getattr(term, c) for c in colstr.split()] + ['%s', term.NORMAL]
            self.color_fmt[levelno] = ''.join(slist)
开发者ID:merriam,项目名称:beancount,代码行数:12,代码来源:colorlog.py

示例7: __init__

# 需要导入模块: from logging import Formatter [as 别名]
# 或者: from logging.Formatter import __init__ [as 别名]
 def __init__(self,recordfields = [], datefmt=None, customjson=None):
     """__init__ overrides the default constructor to accept a formatter specific list of metadata fields 
     
     Args:
         recordfields : A list of strings referring to metadata fields on the record object. It can be empty.
                        The list of fields will be added to the JSON record created by the formatter. 
     """
     Formatter.__init__(self,None,datefmt)
     self.recordfields = recordfields
     self.customjson   = customjson
开发者ID:NyproTheGeek,项目名称:Managed-Files,代码行数:12,代码来源:recipe-580667.py

示例8: __init__

# 需要导入模块: from logging import Formatter [as 别名]
# 或者: from logging.Formatter import __init__ [as 别名]
	def __init__ (self, format, datefmt=None, log_colors=default_log_colors, reset=True, style='%'):
		"""
		:Parameters:
		- format (str): The format string to use
		- datefmt (str): A format string for the date
		- log_colors (dict): A mapping of log level names to color names
		- reset (bool): Implictly appends a reset code to all records unless set to False
		- style ('%' or '{' or '$'): The format style to use. No meaning prior to Python 3.2.
		
		The ``format``, ``datefmt`` and ``style`` args are passed on to the Formatter constructor.
		"""
		if version_info > (3, 2):
			super(ColoredFormatter, self).__init__(format, datefmt, style=style)
		elif version_info > (2, 7):
			super(ColoredFormatter, self).__init__(format, datefmt)
		else:
			Formatter.__init__(self, format, datefmt)
		self.log_colors = log_colors
		self.reset = reset
开发者ID:EdhecRiskInstitute,项目名称:colorlog,代码行数:21,代码来源:colorlog.py

示例9: __init__

# 需要导入模块: from logging import Formatter [as 别名]
# 或者: from logging.Formatter import __init__ [as 别名]
 def __init__(self, display_date=True, datefmt=None):
     Formatter.__init__(self, datefmt=datefmt)
     self.display_date = display_date
开发者ID:maximerobin,项目名称:Ufwi,代码行数:5,代码来源:logger.py

示例10: __init__

# 需要导入模块: from logging import Formatter [as 别名]
# 或者: from logging.Formatter import __init__ [as 别名]
 def __init__(self):
     Formatter.__init__(self)
开发者ID:NoviceLive,项目名称:pat,代码行数:4,代码来源:init.py

示例11: __init__

# 需要导入模块: from logging import Formatter [as 别名]
# 或者: from logging.Formatter import __init__ [as 别名]
 def __init__(self, fmt=None, datefmt=None, colorize=None):
     Formatter.__init__(self, fmt, datefmt)
     if colorize:
         self.colorize = colorize
     else:
         self.colorize = lambda c, s: s
开发者ID:birkenfeld,项目名称:conduct,代码行数:8,代码来源:loggers.py

示例12: __init__

# 需要导入模块: from logging import Formatter [as 别名]
# 或者: from logging.Formatter import __init__ [as 别名]
 def __init__(self):
     Formatter.__init__(
         self,
         '%(colour)s[%(asctime)s][%(level)-4s] %(message)s%(end)s',
         '%Y-%m-%dT%H:%M:%S'
     )
开发者ID:robhardwick,项目名称:music-library-py,代码行数:8,代码来源:log.py

示例13: __init__

# 需要导入模块: from logging import Formatter [as 别名]
# 或者: from logging.Formatter import __init__ [as 别名]
 def __init__(self, prefix="", only_from=None):
     Formatter.__init__(self)
     self._info_fmt = prefix + "%(message)s"
     self._fmt = prefix + "%(levelname)s (%(name)s): %(message)s"
     self._only_from = only_from
开发者ID:Bowen-C,项目名称:pylearn2,代码行数:7,代码来源:logger.py

示例14: __init__

# 需要导入模块: from logging import Formatter [as 别名]
# 或者: from logging.Formatter import __init__ [as 别名]
 def __init__(self, patern):
     Formatter.__init__(self, patern)
开发者ID:LinuxCNC,项目名称:linuxcnc,代码行数:4,代码来源:colored_formatter.py

示例15: __init__

# 需要导入模块: from logging import Formatter [as 别名]
# 或者: from logging.Formatter import __init__ [as 别名]
 def __init__(self, fmt=None, datefmt=None):
     Formatter.__init__(self, fmt=fmt, datefmt=datefmt)
     self._fmt = fmt or self.DEFAULT_FMT
     self.datefmt = datefmt or self.DEFAULT_DATEFMT
开发者ID:laurb9,项目名称:rich-traceback,代码行数:6,代码来源:formatter.py


注:本文中的logging.Formatter.__init__方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。