コード例 #1
0
  /**
   * Open event starts with a random value that the checksum will be based off of.
   *
   * <p>Use the host and the nanos as a tag at the collector side.
   */
  public Event openEvent() {
    Event e = new EventImpl(new byte[0]);
    e.set(ATTR_ACK_TYPE, CHECKSUM_START);
    checksum = e.getTimestamp();
    e.set(ATTR_ACK_HASH, ByteBuffer.allocate(8).putLong(checksum).array());
    e.set(ATTR_ACK_TAG, tag);

    return e;
  }
コード例 #2
0
 private String format(Event e) {
   Date d = new Date(e.getTimestamp());
   String data =
       String.format(
           "%s %s %s: %s\n",
           DateUtils.asISO8601(d),
           e.getPriority(),
           "log4j",
           StringEscapeUtils.escapeJava(new String(e.getBody())));
   return data;
 }
コード例 #3
0
  @Override
  public void append(Event e) throws IOException, InterruptedException {
    String helloWorldBody = "Hello World! -- " + new String(e.getBody());

    // make a copy of the event, but with the new body string.
    EventImpl e2 =
        new EventImpl(
            helloWorldBody.getBytes(),
            e.getTimestamp(),
            e.getPriority(),
            e.getNanos(),
            e.getHost(),
            e.getAttrs());

    super.append(e2);
  }