Java 类org.apache.logging.log4j.core.net.Priority 实例源码

项目:log4j2    文件:SyslogLayout.java   
/**
 * Formats a {@link org.apache.logging.log4j.core.LogEvent} in conformance with the BSD Log record format.
 *
 * @param event The LogEvent
 * @return the event formatted as a String.
 */
@Override
public String toSerializable(final LogEvent event) {
    final StringBuilder buf = new StringBuilder();

    buf.append("<");
    buf.append(Priority.getPriority(facility, event.getLevel()));
    buf.append(">");
    addDate(event.getMillis(), buf);
    buf.append(" ");
    buf.append(localHostname);
    buf.append(" ");

    String message = event.getMessage().getFormattedMessage();
    if (null != escapeNewLine) {
        message = NEWLINE_PATTERN.matcher(message).replaceAll(escapeNewLine);
    }
    buf.append(message);

    if (includeNewLine) {
        buf.append("\n");
    }
    return buf.toString();
}
项目:logging-log4j2    文件:SyslogLayout.java   
/**
 * Formats a {@link org.apache.logging.log4j.core.LogEvent} in conformance with the BSD Log record format.
 *
 * @param event The LogEvent
 * @return the event formatted as a String.
 */
@Override
public String toSerializable(final LogEvent event) {
    final StringBuilder buf = getStringBuilder();

    buf.append('<');
    buf.append(Priority.getPriority(facility, event.getLevel()));
    buf.append('>');
    addDate(event.getTimeMillis(), buf);
    buf.append(Chars.SPACE);
    buf.append(localHostname);
    buf.append(Chars.SPACE);

    String message = event.getMessage().getFormattedMessage();
    if (null != escapeNewLine) {
        message = NEWLINE_PATTERN.matcher(message).replaceAll(escapeNewLine);
    }
    buf.append(message);

    if (includeNewLine) {
        buf.append('\n');
    }
    return buf.toString();
}
项目:logging-log4j2    文件:SyslogAppenderTestBase.java   
protected void checkTheEqualityOfSentAndReceivedMessages(final Level expectedLevel) throws InterruptedException {
    final List<String> receivedMessages = getReceivedMessages(DEFAULT_TIMEOUT_IN_MS);

    assertNotNull("No messages received", receivedMessages);
    for (int i = 0; i < receivedMessages.size(); i++) {
        final String receivedMessage = receivedMessages.get(i);
        final String sentMessage = sentMessages.get(i);
        final String suffix = includeNewLine ? "\n" : Strings.EMPTY;
        assertTrue("Incorrect message received: " + receivedMessage,
                receivedMessage.endsWith(sentMessage + suffix) || receivedMessage.contains(sentMessage));
        final int expectedPriority = Priority.getPriority(getExpectedFacility(), expectedLevel);
        assertTrue("Expected facility " + expectedPriority + " in message " + receivedMessage,
                receivedMessage.startsWith("<" + expectedPriority + ">"));
    }
}
项目:log4j2    文件:RFC5424Layout.java   
private void appendPriority(final StringBuilder buffer, final Level logLevel) {
    buffer.append("<");
    buffer.append(Priority.getPriority(facility, logLevel));
    buffer.append(">1 ");
}
项目:logging-log4j2    文件:Rfc5424Layout.java   
private void appendPriority(final StringBuilder buffer, final Level logLevel) {
    buffer.append('<');
    buffer.append(Priority.getPriority(facility, logLevel));
    buffer.append(">1 ");
}