import bitmovin
# Initialize the API once, call a method, results in one log line.
api = bitmovin.Bitmovin(api_key='SECRET_CODE')
api.inputs.HTTPS.list()
# […datetime…] bitmovin.rest.http_client.BitmovinHttpClient INFO REQUEST: GET encoding/inputs/https?offset=0&limit=100
# Initialize the API additional times, call a method, results in multiple log lines.
bitmovin.Bitmovin(api_key='SECRET_CODE')
bitmovin.Bitmovin(api_key='SECRET_CODE')
api.inputs.HTTPS.list()
# […datetime…] bitmovin.rest.http_client.BitmovinHttpClient INFO REQUEST: GET encoding/inputs/https?offset=0&limit=100
# […datetime…] bitmovin.rest.http_client.BitmovinHttpClient INFO REQUEST: GET encoding/inputs/https?offset=0&limit=100
# […datetime…] bitmovin.rest.http_client.BitmovinHttpClient INFO REQUEST: GET encoding/inputs/https?offset=0&limit=100
Perhaps simply check if one or more handlers already exist, for example:
class BitmovinObject(object):
def __init__(self, *args, **kwargs):
self.logger = logging.getLogger(self.__class__.__module__ + "." + self.__class__.__name__)
if not self.logger.hasHandlers():
self.logger.setLevel(logging.DEBUG)
console_handler = logging.StreamHandler(sys.stdout)
formatter = logging.Formatter('%(asctime)-15s %(name)-5s %(levelname)-8s %(message)s')
console_handler.setFormatter(formatter)
self.logger.addHandler(console_handler)
Currently a new console logging handler is attached to the BitmovinObject each time it is initialized: https://github.com/bitmovin/bitmovin-python/blob/master/bitmovin/bitmovin_object.py#L12 This causes multiple log outputs for the same log call if the API is initialized multiple times.
Perhaps simply check if one or more handlers already exist, for example: