def start(endpoint='data.logentries.com',
          port=10000,
          token=None,
          tag='salt/engines/logentries'):
    '''
    Listen to salt events and forward them to Logentries
    '''
    if __opts__.get('id').endswith('_master'):
        event_bus = salt.utils.event.get_master_event(
            __opts__,
            __opts__['sock_dir'],
            listen=True)
    else:
        event_bus = salt.utils.event.get_event(
            'minion',
            transport=__opts__['transport'],
            opts=__opts__,
            sock_dir=__opts__['sock_dir'],
            listen=True)
    log.debug('Logentries engine started')

    try:
        val = uuid.UUID(token)
    except __HOLE__:
        log.warning('Not a valid logentries token')

    appender = _get_appender(endpoint, port)
    appender.reopen_connection()

    while True:
        event = event_bus.get_event()
        if event:
            msg = '{0} {1}'.format(tag, json.dumps(event))
            appender.put(_emit(token, msg))

    appender.close_connection()
dataset/ETHPy150Open saltstack/salt/salt/engines/logentries.py/start