def __init__(self, beaver_config, logger=None):
        """Generic transport configuration
        Will attach the file_config object, setup the
        current hostname, and ensure we have a proper
        formatter for the current transport
        """
        self._beaver_config = beaver_config
        self._current_host = beaver_config.get('hostname')
        self._default_formatter = beaver_config.get('format', 'null')
        self._formatters = {}
        self._is_valid = True
        self._logger = logger
        self._epoch = datetime.datetime.utcfromtimestamp(0)

        self._logstash_version = beaver_config.get('logstash_version')
        if self._logstash_version == 0:
            self._fields = {
                'type': '@type',
                'tags': '@tags',
                'message': '@message',
                'file': '@source_path',
                'host': '@source_host',
                'raw_json_fields': ['@message', '@source', '@source_host', '@source_path', '@tags', '@timestamp', '@type'],
            }
        elif self._logstash_version == 1:
            self._fields = {
                'type': 'type',
                'tags': 'tags',
                'message': 'message',
                'file': 'file',
                'host': 'host',
                'raw_json_fields': ['message', 'host', 'file', 'tags', '@timestamp', 'type'],
            }

        def raw_formatter(data):
            return data[self._fields.get('message')]

        def rawjson_formatter(data):
            try:
                json_data = json.loads(data[self._fields.get('message')])
            except __HOLE__:
                self._logger.warning("cannot parse as rawjson: {0}".format(self._fields.get('message')))
                json_data = json.loads("{}")
            if json_data:
                del data[self._fields.get('message')]

            for field in json_data:
                data[field] = json_data[field]

            for field in self._fields.get('raw_json_fields'):
                if field not in data:
                    data[field] = ''

            return json.dumps(data)

        def gelf_formatter(data):
            message = data[self._fields.get('message')]
            short_message = message.split('\n', 1)[0]
            short_message = short_message[:250]

            timestampDate = datetime.datetime.strptime(data['@timestamp'], "%Y-%m-%dT%H:%M:%S.%fZ")

            delta = timestampDate - self._epoch
            timestampSeconds = delta.days*86400+delta.seconds+delta.microseconds/1e6

            gelf_data = {
                'version': '1.1',
                'host': data[self._fields.get('host')],
                'short_message': short_message,
                'full_message': message,
                'timestamp': timestampSeconds,
                'level': 6,
                '_file': data[self._fields.get('file')],
            }

            return json.dumps(gelf_data) + '\0'

        def string_formatter(data):
            return '[{0}] [{1}] {2}'.format(data[self._fields.get('host')], data['@timestamp'], data[self._fields.get('message')])

        self._formatters['json'] = json.dumps
        self._formatters['msgpack'] = msgpack.packb
        self._formatters['raw'] = raw_formatter
        self._formatters['rawjson'] = rawjson_formatter
        self._formatters['string'] = string_formatter
        self._formatters['gelf'] = gelf_formatter
dataset/ETHPy150Open python-beaver/python-beaver/beaver/transports/base_transport.py/BaseTransport.__init__