本文整理汇总了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
示例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)
示例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
示例4: __init__
# 需要导入模块: from logging import Handler [as 别名]
# 或者: from logging.Handler import __init__ [as 别名]
def __init__(self, context=None):
self._set_context(context)
示例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)
示例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 = []
示例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)
示例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
示例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)