<commit_before>#!/usr/bin/env python3
# -*- coding:utf-8 -*-
'''
package of logging handler which send messages to Slack
'''
import logging
import simplejson as json
import requests

__version__ = '0.1.0'
__url = 'https://github.com/tetutaro/slack_logging_handler'
__author = 'maruyama'


class SlackLoggingHandler(logging.Handler):
	default_emojis = {
		logging.NOTSET: ':question:',
		logging.DEBUG: ':thought_balloon:',
		logging.INFO: ':speech_balloon:',
		logging.WARNING: ':right_anger_bubble:',
		logging.ERROR: ':mega:',
		logging.CRITICAL: ':loudspeaker:',
	}

	def __init__(
		self, webhook_url, channel=None, username=None, emojis=None,
		format='%(asctime)s: %(module)s-%(name)s: %(message)s'
	):
		logging.Handler.__init__(self)
		self.webhook_url = webhook_url
		self.channel = channel
		self.username = username
		self.formatter = logging.Formatter(format)
		if emojis is not None:
			self.emojis = emojis
		else:<commit_msg>set webhook url as 'url' option (for dictConfig)<commit_after>#!/usr/bin/env python3
# -*- coding:utf-8 -*-
'''
package of logging handler which send messages to Slack
'''
import logging
import simplejson as json
import requests

__version__ = '0.1.0'
__url = 'https://github.com/tetutaro/slack_logging_handler'
__author = 'maruyama'


class SlackLoggingHandler(logging.Handler):
	default_emojis = {
		logging.NOTSET: ':question:',
		logging.DEBUG: ':thought_balloon:',
		logging.INFO: ':speech_balloon:',
		logging.WARNING: ':right_anger_bubble:',
		logging.ERROR: ':mega:',
		logging.CRITICAL: ':loudspeaker:',
	}

	def __init__(
		self, url=None, channel=None, username=None, emojis=None,
		format='%(asctime)s: %(module)s-%(name)s: %(message)s'
	):
		logging.Handler.__init__(self)
		if url is None:
			raise ValueError('url must be set')
		self.webhook_url = url
		self.channel = channel
		self.username = username
		self.formatter = logging.Formatter(format)
		if emojis is not None:
			self.emojis = emojis
		else:
{'fraction_non_alphanumeric': 0.14482406935237124, 'fraction_numerical': 0.005099439061703213, 'mean_word_length': 4.874251497005988, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6519538', 'n_tokens_mistral': 760, 'n_tokens_neox': 692, 'n_words': 151}