Writes an ``Event`` object to Splunk.

        :param event: An ``Event`` object.
541210
def write_event(self, event):
        

        if not self.header_written:
            self._out.write("<stream>")
            self.header_written = True

        event.write_to(self._out)
615938
public void offerEvent(final Event event) throws IOException
    {
        if (!acceptEvents.get()) {
            // TODO shouldn't we increment eventsLost here?
            return;
        }

        eventsReceived.incrementAndGet();

        try {
            log.debug("Writing event: {}", event);
            eventWriter.write(event);
        }
        catch (IOException e) {
            log.error(String.format("Failed to write event: %s", event), e);
            eventsLost.incrementAndGet();

            throw e;
        }
    }
1268855
def write_event(self, event):
        """"""
        # Check if event is of type event_pb2.Event proto.
        if not isinstance(event, event_pb2.Event):
            raise TypeError("expected an event_pb2.Event proto, "
                            " but got %s" % type(event))
        return self._write_serialized_event(event.SerializeToString())
269709
def put(self, event, *args, **kwargs):
        
        self._queue.put((event, args, kwargs))
41733
def WriteEventBody(self, event):
    
    inode = getattr(event, 'inode', None)
    if inode is None:
      event.inode = 0

    json_dict = self._JSON_SERIALIZER.WriteSerializedDict(event)
    json_string = json.dumps(json_dict, sort_keys=True)

    if self._event_counter != 0:
      self._output_writer.Write(', ')

    line = '"event_{0:d}": {1:s}\n'.format(self._event_counter, json_string)
    self._output_writer.Write(line)

    self._event_counter += 1
239965
def _generate_event_doc(event):
    '''
    
    '''

    # Create a copy of the object that we will return.
    eventc = event.copy()

    # Set the ID of the document to be the JID.
    eventc["_id"] = '{}-{}'.format(
                                    event.get('tag', '').split('/')[2],
                                    event.get('tag', '').split('/')[3]
                                  )

    # Add a timestamp field to the document
    eventc["timestamp"] = time.time()

    # remove any return data as it's captured in the "returner" function
    if eventc.get('data').get('return'):
        del eventc['data']['return']

    return eventc
177644
def WriteEventBody(self, event):
    
    inode = getattr(event, 'inode', None)
    if inode is None:
      event.inode = 0

    try:
      message, _ = self._output_mediator.GetFormattedMessages(event)
    except errors.WrongFormatter:
      message = None

    if message:
      event.message = message

    json_dict = self._JSON_SERIALIZER.WriteSerializedDict(event)
    json_string = json.dumps(json_dict, sort_keys=True)
    # dumps() returns an ascii-encoded byte string in Python 2.
    if py2to3.PY_2:
      json_string = codecs.decode(json_string, 'ascii')
    self._output_writer.Write(json_string)
    self._output_writer.Write('\n')
937357
private void write(IRTMPEvent event, Number streamId) {
        log.trace("write to stream id: {} channel: {}", streamId, id);
        final Header header = new Header();
        final Packet packet = new Packet(header, event);
        // set the channel id
        header.setChannelId(id);
        int ts = event.getTimestamp();
        if (ts != 0) {
            header.setTimer(event.getTimestamp());
        }
        header.setStreamId(streamId);
        header.setDataType(event.getDataType());
        // should use RTMPConnection specific method.. 
        //log.trace("Connection type for write: {}", connection.getClass().getName());
        connection.write(packet);
    }
765161
@Override
    public synchronized void write(final Event event) throws IOException
    {
        if (!acceptsEvents) {
            log.warn("Writer not ready, discarding event: {}", event);
            return;
        }

        delegate.write(event);
        uncommittedWriteCount++;

        commitIfNeeded();
    }
20312
def send(self, event):
        # type(Event) -> bytes
        
        data = b""
        if isinstance(event, Request):
            data += self._initiate_connection(event)
        elif isinstance(event, AcceptConnection):
            data += self._accept(event)
        elif isinstance(event, RejectConnection):
            data += self._reject(event)
        elif isinstance(event, RejectData):
            data += self._send_reject_data(event)
        else:
            raise LocalProtocolError(
                "Event {} cannot be sent during the handshake".format(event)
            )
        return data
496017
def write_event(self, event):
    
    self._lock.acquire()
    try:
      self._events_writer.WriteEvent(event)
      self._event_count += 1
      if self._always_flush:
        # We flush on every event within the integration test.
        self._events_writer.Flush()

      if self._event_count == self._check_this_often:
        # Every so often, we check whether the size of the file is too big.
        self._event_count = 0

        # Flush to get an accurate size check.
        self._events_writer.Flush()

        file_path = os.path.join(self._events_directory,
                                 self.get_current_file_name())
        if not tf.io.gfile.exists(file_path):
          # The events file does not exist. Perhaps the user had manually
          # deleted it after training began. Create a new one.
          self._events_writer.Close()
          self._events_writer = self._create_events_writer(
              self._events_directory)
        elif tf.io.gfile.stat(file_path).length > self._single_file_size_cap_bytes:
          # The current events file has gotten too big. Close the previous
          # events writer. Make a new one.
          self._events_writer.Close()
          self._events_writer = self._create_events_writer(
              self._events_directory)
    except IOError as err:
      logger.error(
          "Writing to %s failed: %s", self.get_current_file_name(), err)
    self._lock.release()
638578
def dump_to_log(self):
        
        if self._event_dict:
            logger.info('Events:')
            for event_str, count_int in sorted(self._event_dict.items()):
                logger.info('  {}: {}'.format(event_str, count_int))
        else:
            logger.info('No Events')
660821
def _send_splunk(event, index_override=None, sourcetype_override=None):
    '''
    

    '''
    # Get Splunk Options
    opts = _get_options()
    log.info(str('Options: %s'),  # future lint: disable=blacklisted-function
             salt.utils.json.dumps(opts))
    http_event_collector_key = opts['token']
    http_event_collector_host = opts['indexer']
    # Set up the collector
    splunk_event = http_event_collector(http_event_collector_key, http_event_collector_host)
    # init the payload
    payload = {}

    # Set up the event metadata
    if index_override is None:
        payload.update({"index": opts['index']})
    else:
        payload.update({"index": index_override})
    if sourcetype_override is None:
        payload.update({"sourcetype": opts['sourcetype']})
    else:
        payload.update({"index": sourcetype_override})

    # Add the event
    payload.update({"event": event})
    log.info(str('Payload: %s'),  # future lint: disable=blacklisted-function
             salt.utils.json.dumps(payload))
    # Fire it off
    splunk_event.sendEvent(payload)
    return True
1061526
def PushEvent(self, event):
    
    event_string = event.GetAttributeValuesString()
    heap_values = (event.timestamp, event.timestamp_desc, event_string, event)
    heapq.heappush(self._heap, heap_values)
703180
function (config) {
        var stream =  new SplunkStream(config);
        /**
         * @typedef SplunkBunyanStream
         * @property {string} level The logging level for Bunyan.
         * @property {string} type Always <code>raw</code>.
         * @property {function} on Takes an <code>event</code> string, and a callback function.
         * The most useful event to listen for is <code>error</code>.
         * See {@link https://nodejs.org/api/events.html#events_emitter_on_event_listener|Node.js events} documentation.
         * @property {function} setEventFormatter Overrides the eventFormatter for the underlying SplunkLogger.
         * Takes a callback function parameter: <code>function(message, severity)</code>, where message
         * is an object, and severity is a string.
         * @property {function} on Adds a listener to to the SplunkStream object, typically used for the error event.
         * @property {function} flush Manually sends all queued events to Splunk in a single HTTP request.
         * Takes a callback function parameter: <code>function(err, response, body)</code>.
         * @property {SplunkStream} stream See {@link SplunkStream}
         */
        return {
            level: config.level || module.exports.levels.INFO,
            type: "raw",
            setEventFormatter: function(formatter) {
                this.stream.logger.eventFormatter = formatter;
            },
            on: function(event, callback) {
                this.stream.on(event, callback);
            },
            flush: function(callback) {
                // If flush is called with no param, use the send() callback
                callback = callback || this.stream.send;
                this.stream.logger.flush(callback);
            },
            stream: stream
        };
    }
342734
def WriteEventBody(self, event):
    
    for field_name in self._fields:
      if field_name == 'datetime':
        output_value = self._FormatDateTime(event)
      else:
        output_value = self._dynamic_fields_helper.GetFormattedField(
            event, field_name)

      output_value = self._RemoveIllegalXMLCharacters(output_value)

      # Auto adjust the column width based on the length of the output value.
      column_index = self._fields.index(field_name)
      self._column_widths.setdefault(column_index, 0)

      if field_name == 'datetime':
        column_width = min(
            self._MAX_COLUMN_WIDTH, len(self._timestamp_format) + 2)
      else:
        column_width = min(self._MAX_COLUMN_WIDTH, len(output_value) + 2)

      self._column_widths[column_index] = max(
          self._MIN_COLUMN_WIDTH, self._column_widths[column_index],
          column_width)
      self._sheet.set_column(
          column_index, column_index, self._column_widths[column_index])

      if (field_name == 'datetime'
          and isinstance(output_value, datetime.datetime)):
        self._sheet.write_datetime(
            self._current_row, column_index, output_value)
      else:
        self._sheet.write(self._current_row, column_index, output_value)

    self._current_row += 1
577104
def write_events(stream, events):
    '''
    
    '''
    for event in events:
        data = event.SerializeToString()
        len_field = struct.pack('<Q', len(data))
        len_crc = struct.pack('<I', masked_crc(len_field))
        data_crc = struct.pack('<I', masked_crc(data))
        stream.write(len_field)
        stream.write(len_crc)
        stream.write(data)
        stream.write(data_crc)