def __init__(self, spec, host='<STR_LIT:127.0.0.1>', port=<NUM_LIT>, buff=<NUM_LIT:1000>, id_field=None, updated_field='<STR_LIT>',<EOL>upsert=False):
import pymongo<EOL>LOG.warn(pymongo.get_version_string())<EOL>args = spec.split("<STR_LIT:U+002C>", <NUM_LIT:1>)<EOL>self.db_name, self.coll = args[<NUM_LIT:0>].split("<STR_LIT:.>")<EOL>opts = utils.to_dict(args[<NUM_LIT:1>]) if len(args) > <NUM_LIT:1> else {}<EOL>self.host = opts.get("<STR_LIT:host>", host)<EOL>self.port = opts.get("<STR_LIT:port>", port)<EOL>self.buffer = opts.get("<STR_LIT:b>", buff)<EOL>self.id_field = opts.get("<STR_LIT:id>", id_field)<EOL>self.updated_field = opts.get("<STR_LIT>", updated_field)<EOL>self.upsert = ('<STR_LIT:%s>' % opts.get("<STR_LIT>", upsert)).lower() == "<STR_LIT:true>"<EOL>self.pymongo_client = pymongo.MongoClient<EOL>self.pymongo_errors = pymongo.errors<EOL>def do_connect():<EOL><INDENT>return self.do_connect()<EOL><DEDENT>def do_close():<EOL><INDENT>return self.do_close(self.conn)<EOL><DEDENT>self.conn = utils.Connector(do_connect, do_close)<EOL>self.conn.connect()<EOL>
Constructs a MongoDB output
:param spec: A string for embedding options, e.g. 'host=example.com,port=80,id=_id,ts=created:updated
:param host: The MongoDB host, defaults to localhost
:param port: The MongoDB port, defaults to 27017, the default MongoDB port
:param buff: The number of documents to accumulate for each DB TX
:param id_field: The event field that should be used as the ID