protected String combine(SyslogIF syslog, int level, String message, String reason) {
    // Note: syslog is explicitly ignored by default

    String _message = message != null ? message : "UNKNOWN";
    String _reason = reason != null ? reason : "UNKNOWN";

    String combinedMessage = SyslogUtility.getLevelString(level) + " " + _message;

    if (this.appendReason) {
      combinedMessage += " [" + _reason + "]";
    }

    return combinedMessage;
  }
Пример #2
0
  public String modify(
      SyslogIF syslog, SyslogConfigIF syslogConfig, int facility, int level, String message) {
    byte[] messageBytes = SyslogUtility.getBytes(syslogConfig, message);

    MessageDigest digest = obtainMessageDigest();
    byte[] digestBytes = digest.digest(messageBytes);

    String digestString = Base64.encodeBytes(digestBytes, Base64.DONT_BREAK_LINES);

    StringBuffer buffer = new StringBuffer(message);

    buffer.append(this.config.getPrefix());
    buffer.append(digestString);
    buffer.append(this.config.getSuffix());

    return buffer.toString();
  }