def __init__(self, app_name, elastic_url, headers=None, auth=None):
"""Initialize the ElasticLoggger class.
Args:
app_name (str) :Name of the application which is using current logger
elastic_url (str) :Url of elastic-http-input to push logs to (for eg. 'http://localhost:3332' )
headers (str) :Since this is post request headers are required, defaults to {'content-type': 'application/json'}
auth (tuple) :A tuple containing username and password: for eg. ('myuser', 'mypassword')
"""
self.elastic_url = elastic_url
self.auth = auth
self.headers = headers
if not self.headers:
self.headers = {'content-type': 'application/json'}
self.debug_method = partial(self.__log, level='debug')
self.error_method = partial(self.__log, level='error')
self.info_method = partial(self.__log, level='info')
self.exception_method = partial(self.__log, level='exception')
self.session = FuturesSession(max_workers=10)
self.app_name = app_name
评论列表
文章目录