private Builder() { this.layout = SerializedLayout.createLayout(); this.ignoreExceptions = true; }
protected org.apache.logging.log4j.core.Layout buildLayout(String encoding) { org.apache.logging.log4j.core.Layout layout = org.apache.logging.log4j.core.layout.PatternLayout.newBuilder(). withConfiguration(configuration) .withPattern(LoggerHelper.getPattern()) .withCharset(Charset.forName(encoding)) .build(); return layout; }
private String prepareXMLForStacktraceTests(final boolean stacktraceAsString) { final Log4jLogEvent expected = LogEventFixtures.createLogEvent(); // @formatter:off final AbstractJacksonLayout layout = XmlLayout.newBuilder() .setCompact(true) .setIncludeStacktrace(true) .setStacktraceAsString(stacktraceAsString) .build(); // @formatter:off return layout.toSerializable(expected); }
private static PatternLayout createPatternLayout() { return PatternLayout.newBuilder().withPattern(PatternLayout.SIMPLE_CONVERSION_PATTERN) .build(); }
@Test public void testIncludeNullDelimiterFalse() throws Exception { final AbstractJacksonLayout layout = JsonLayout.newBuilder() .setCompact(true) .setIncludeNullDelimiter(false) .build(); final String str = layout.toSerializable(LogEventFixtures.createLogEvent()); assertFalse(str.endsWith("\0")); }
private String prepareJSONForStacktraceTests(final boolean stacktraceAsString) { final Log4jLogEvent expected = LogEventFixtures.createLogEvent(); // @formatter:off final AbstractJacksonLayout layout = JsonLayout.newBuilder() .setCompact(true) .setIncludeStacktrace(true) .setStacktraceAsString(stacktraceAsString) .build(); // @formatter:off return layout.toSerializable(expected); }
@Test public void testIncludeNullDelimiterTrue() throws Exception { final AbstractJacksonLayout layout = XmlLayout.newBuilder() .setCompact(true) .setIncludeNullDelimiter(true) .build(); final String str = layout.toSerializable(LogEventFixtures.createLogEvent()); assertTrue(str.endsWith("\0")); }
private String prepareYAMLForStacktraceTests(final boolean stacktraceAsString) { final Log4jLogEvent expected = LogEventFixtures.createLogEvent(); // @formatter:off final AbstractJacksonLayout layout = YamlLayout.newBuilder() .setIncludeStacktrace(true) .setStacktraceAsString(stacktraceAsString) .build(); // @formatter:off return layout.toSerializable(expected); }
@Test public void testIncludeNullDelimiterTrue() throws Exception { final AbstractJacksonLayout layout = YamlLayout.newBuilder() .setIncludeNullDelimiter(true) .build(); final String str = layout.toSerializable(LogEventFixtures.createLogEvent()); assertTrue(str.endsWith("\0")); }
@Test public void testContentType() { final HtmlLayout layout = HtmlLayout.newBuilder() .withContentType("text/html; charset=UTF-16") .build(); assertEquals("text/html; charset=UTF-16", layout.getContentType()); // TODO: make sure this following bit works as well // assertEquals(Charset.forName("UTF-16"), layout.getCharset()); }
@Override public void writeBytes(final byte[] data, final int offset, final int length) { ByteBufferDestinationHelper.writeToUnsynchronized(data, offset, length, this); } }
private void testLayout(final CSVFormat format) { testLayout(format, CsvLogEventLayout.createLayout(format), null, null); }
public static StringBuilder getStringBuilder() { return AbstractStringLayout.getStringBuilder(); }
@Test public void testContentType() { final AbstractJacksonLayout layout = YamlLayout.createDefaultLayout(); assertEquals("application/yaml; charset=UTF-8", layout.getContentType()); }
@Test public void testDefaultCharset() { final AbstractJacksonLayout layout = YamlLayout.createDefaultLayout(); assertEquals(StandardCharsets.UTF_8, layout.getCharset()); }
@Test public void testDefaultCharset() { final AbstractJacksonLayout layout = JsonLayout.createDefaultLayout(); assertEquals(StandardCharsets.UTF_8, layout.getCharset()); }
@Test public void testIncludeNullDelimiterTrue() throws Exception { final AbstractJacksonLayout layout = JsonLayout.newBuilder() .setCompact(true) .setIncludeNullDelimiter(true) .build(); final String str = layout.toSerializable(LogEventFixtures.createLogEvent()); assertTrue(str.endsWith("\0")); }
@Test public void testIncludeNullDelimiterFalse() throws Exception { final AbstractJacksonLayout layout = XmlLayout.newBuilder() .setCompact(true) .setIncludeNullDelimiter(false) .build(); final String str = layout.toSerializable(LogEventFixtures.createLogEvent()); assertFalse(str.endsWith("\0")); } }
@Test public void testIncludeNullDelimiterFalse() throws Exception { final AbstractJacksonLayout layout = YamlLayout.newBuilder() .setIncludeNullDelimiter(false) .build(); final String str = layout.toSerializable(LogEventFixtures.createLogEvent()); assertFalse(str.endsWith("\0")); }
@Override public void writeBytes(final ByteBuffer data) { ByteBufferDestinationHelper.writeToUnsynchronized(data, this); }