U vâ’i£ ã @ s. d Z ddlZddlmZ G dd„ dejƒZdS )z3Use the influxdb_client with python native logging.é N)ÚInfluxDBClientc s€ e Zd ZdZee i ¡j ¡ ƒdg Z dddœ‡ fdd„ Z dd„ Zdd œ‡ fd d„Zej ddœd d„Zej edœdd„Z‡ ZS )ÚInfluxLoggingHandlerz² InfluxLoggingHandler instances dispatch logging events to influx. There is no need to set a Formatter. The raw input will be passed on to the influx write api. ÚmessageN)Úclient_argsÚwrite_api_argsc s\ t ƒ ¡ || _|dkri n|}tf |||dœ|—Ž| _|dkrDi n|}| jjf |Ž| _dS )zË Initialize defaults. The arguments `client_args` and `write_api_args` can be dicts of kwargs. They are passed on to the InfluxDBClient and write_api calls respectively. N)ÚurlÚtokenÚorg)ÚsuperÚ__init__Úbucketr ÚclientÚ write_api)Úselfr r r r r r ©Ú __class__© úW/opt/alt/python38/lib/python3.8/site-packages/influxdb_client/client/logging_handler.pyr s zInfluxLoggingHandler.__init__c C s | ¡ dS )z#Make sure all resources are closed.N)Úclose©r r r r Ú__del__" s zInfluxLoggingHandler.__del__)Úreturnc s" | j ¡ | j ¡ tƒ ¡ dS )z'Close the write_api, client and logger.N)r r r r r r r r r &