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


Python Handler.__init__方法代码示例

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


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

示例1: __init__

# 需要导入模块: from logging import Handler [as 别名]
# 或者: from logging.Handler import __init__ [as 别名]
def __init__(self, debug=False, version='1.1', include_extra_fields=False, compress=False,
                 static_fields=None, json_default=gelf.object_to_json, **kwargs):
        """
        Logging handler that transforms each record into GELF (graylog extended log format) and sends it over TCP.

        :param debug: include debug fields, e.g. line number, or not
        :param include_extra_fields: include non-default fields from record to message, or not
        :param json_default: function that is called for objects that cannot be serialized to JSON natively by python
        :param kwargs: additional fields that will be included in the log message, e.g. application name.
                       Each additional field should start with underscore, e.g. _app_name
        """

        self.debug = debug
        self.version = version
        self.additional_fields = static_fields if static_fields else kwargs
        self.include_extra_fields = include_extra_fields
        self.additional_fields.pop('_id', None)
        self.domain = socket.gethostname()
        self.compress = compress
        self.json_default = json_default 
开发者ID:keeprocking,项目名称:pygelf,代码行数:22,代码来源:handlers.py

示例2: __init__

# 需要导入模块: from logging import Handler [as 别名]
# 或者: from logging.Handler import __init__ [as 别名]
def __init__(self, conn, queue='log', retry_counts=3, auto_persistence=True):
        Handler.__init__(self)
        self.conn = conn
        self.queue = queue
        assert retry_counts > 0
        self.retry_counts = retry_counts
        self.auto_persistence = auto_persistence
        self.cached_logs = []
        if self.auto_persistence:
            gevent.spawn(self.auto_push)
            atexit.register(self.process_cached_log) 
开发者ID:momosecurity,项目名称:aswan,代码行数:13,代码来源:handler.py

示例3: __init__

# 需要导入模块: from logging import Handler [as 别名]
# 或者: from logging.Handler import __init__ [as 别名]
def __init__(self, filter_components):
        self.inclusive, self.exclusive = self._partition(filter_components)

    # @staticmethod 
开发者ID:singhj,项目名称:locality-sensitive-hashing,代码行数:6,代码来源:logcapture.py

示例4: __init__

# 需要导入模块: from logging import Handler [as 别名]
# 或者: from logging.Handler import __init__ [as 别名]
def __init__(self, context=None):
        self._set_context(context) 
开发者ID:apache,项目名称:airflow,代码行数:4,代码来源:logging_mixin.py

示例5: __init__

# 需要导入模块: from logging import Handler [as 别名]
# 或者: from logging.Handler import __init__ [as 别名]
def __init__(self, parent=None):
        QtCore.QObject.__init__(self, parent)
        Handler.__init__(self) 
开发者ID:ralph-group,项目名称:pymeasure,代码行数:5,代码来源:log.py

示例6: __init__

# 需要导入模块: from logging import Handler [as 别名]
# 或者: from logging.Handler import __init__ [as 别名]
def __init__(self, *args, **kwargs):
        Handler.__init__(self, *args, **kwargs)
        self.errors = [] 
开发者ID:CanonicalLtd,项目名称:landscape-client,代码行数:5,代码来源:testing.py

示例7: __init__

# 需要导入模块: from logging import Handler [as 别名]
# 或者: from logging.Handler import __init__ [as 别名]
def __init__(self, api_key, channel, stack_trace=True, username='Python logger', icon_url=None, icon_emoji=None,
                 fail_silent=False, ping_users=None, ping_level=None):
        Handler.__init__(self)
        self.formatter = NoStacktraceFormatter()

        self.stack_trace = stack_trace
        self.fail_silent = fail_silent

        self.slacker = slacker.Slacker(api_key)

        self.username = username
        self.icon_url = icon_url
        self.icon_emoji = icon_emoji if (icon_emoji or icon_url) else DEFAULT_EMOJI
        self.channel = channel
        if not self.channel.startswith('#') and not self.channel.startswith('@'):
            self.channel = '#' + self.channel

        self.ping_level = ping_level
        self.ping_users = []

        if ping_users:
            user_list = self.slacker.users.list().body['members']

            for ping_user in ping_users:
                ping_user = ping_user.lstrip('@')

                for user in user_list:
                    if user['name'] == ping_user:
                        self.ping_users.append(user['id'])
                        break
                else:
                    raise RuntimeError('User not found in Slack users list: %s' % ping_user) 
开发者ID:mathiasose,项目名称:slacker_log_handler,代码行数:34,代码来源:__init__.py

示例8: __init__

# 需要导入模块: from logging import Handler [as 别名]
# 或者: from logging.Handler 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:zchengquan,项目名称:TextDetector,代码行数:7,代码来源:logger.py

示例9: __init__

# 需要导入模块: from logging import Handler [as 别名]
# 或者: from logging.Handler import __init__ [as 别名]
def __init__(self, base_url=None):
        if(base_url is None):
            self.base_url = 'https://logs-01.loggly.com/inputs/b121e4df-f910-4d6a-b6c1-b19ca2776233/tag/python/'
        else:
            self.base_url = base_url
        self.localip = socket.gethostbyname(socket.gethostname())
        self.publicip = urllib2.urlopen('http://ip.42.pl/raw').read()
        Handler.__init__(self) 
开发者ID:gosquadron,项目名称:squadron,代码行数:10,代码来源:LogglyHandler.py


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