def __init__(self, beaver_config, logger=None):
self._beaver_config = beaver_config<EOL>self._current_host = beaver_config.get('<STR_LIT>')<EOL>self._default_formatter = beaver_config.get('<STR_LIT>', '<STR_LIT:null>')<EOL>self._formatters = {}<EOL>self._is_valid = True<EOL>self._logger = logger<EOL>self._epoch = datetime.datetime.utcfromtimestamp(<NUM_LIT:0>)<EOL>self._logstash_version = beaver_config.get('<STR_LIT>')<EOL>if self._logstash_version == <NUM_LIT:0>:<EOL><INDENT>self._fields = {<EOL>'<STR_LIT:type>': '<STR_LIT>',<EOL>'<STR_LIT>': '<STR_LIT>',<EOL>'<STR_LIT:message>': '<STR_LIT>',<EOL>'<STR_LIT:file>': '<STR_LIT>',<EOL>'<STR_LIT:host>': '<STR_LIT>',<EOL>'<STR_LIT>': ['<STR_LIT>', '<STR_LIT>', '<STR_LIT>', '<STR_LIT>', '<STR_LIT>', '<STR_LIT>', '<STR_LIT>'],<EOL>}<EOL><DEDENT>elif self._logstash_version == <NUM_LIT:1>:<EOL><INDENT>self._fields = {<EOL>'<STR_LIT:type>': '<STR_LIT:type>',<EOL>'<STR_LIT>': '<STR_LIT>',<EOL>'<STR_LIT:message>': '<STR_LIT:message>',<EOL>'<STR_LIT:file>': '<STR_LIT:file>',<EOL>'<STR_LIT:host>': '<STR_LIT:host>',<EOL>'<STR_LIT>': ['<STR_LIT:message>', '<STR_LIT:host>', '<STR_LIT:file>', '<STR_LIT>', '<STR_LIT>', '<STR_LIT:type>'],<EOL>}<EOL><DEDENT>def raw_formatter(data):<EOL><INDENT>return data[self._fields.get('<STR_LIT:message>')]<EOL><DEDENT>def rawjson_formatter(data):<EOL><INDENT>try:<EOL><INDENT>json_data = json.loads(data[self._fields.get('<STR_LIT:message>')])<EOL><DEDENT>except ValueError:<EOL><INDENT>self._logger.warning("<STR_LIT>".format(self._fields.get('<STR_LIT:message>')))<EOL>json_data = json.loads("<STR_LIT:{}>")<EOL><DEDENT>if json_data:<EOL><INDENT>del data[self._fields.get('<STR_LIT:message>')]<EOL><DEDENT>for field in json_data:<EOL><INDENT>data[field] = json_data[field]<EOL><DEDENT>for field in self._fields.get('<STR_LIT>'):<EOL><INDENT>if field not in data:<EOL><INDENT>data[field] = '<STR_LIT>'<EOL><DEDENT><DEDENT>return json.dumps(data)<EOL><DEDENT>def gelf_formatter(data):<EOL><INDENT>message = data[self._fields.get('<STR_LIT:message>')]<EOL>short_message = message.split('<STR_LIT:\n>', <NUM_LIT:1>)[<NUM_LIT:0>]<EOL>short_message = short_message[:<NUM_LIT>]<EOL>timestampDate = datetime.datetime.strptime(data['<STR_LIT>'], "<STR_LIT>")<EOL>delta = timestampDate - self._epoch<EOL>timestampSeconds = delta.days*<NUM_LIT>+delta.seconds+delta.microseconds/<NUM_LIT><EOL>gelf_data = {<EOL>'<STR_LIT:version>': '<STR_LIT>',<EOL>'<STR_LIT:host>': data[self._fields.get('<STR_LIT:host>')],<EOL>'<STR_LIT>': short_message,<EOL>'<STR_LIT>': message,<EOL>'<STR_LIT>': timestampSeconds,<EOL>'<STR_LIT>': <NUM_LIT:6>,<EOL>'<STR_LIT>': data[self._fields.get('<STR_LIT:file>')],<EOL>}<EOL>return json.dumps(gelf_data) + '<STR_LIT>'<EOL><DEDENT>def string_formatter(data):<EOL><INDENT>return '<STR_LIT>'.format(data[self._fields.get('<STR_LIT:host>')], data['<STR_LIT>'], data[self._fields.get('<STR_LIT:message>')])<EOL><DEDENT>self._formatters['<STR_LIT>'] = json.dumps<EOL>self._formatters['<STR_LIT>'] = msgpack.packb<EOL>self._formatters['<STR_LIT>'] = raw_formatter<EOL>self._formatters['<STR_LIT>'] = rawjson_formatter<EOL>self._formatters['<STR_LIT:string>'] = string_formatter<EOL>self._formatters['<STR_LIT>'] = gelf_formatter<EOL>
Generic transport configuration
        Will attach the file_config object, setup the
        current hostname, and ensure we have a proper
        formatter for the current transport