@Test public void testLayoutDefaultNormal() throws Exception { final Logger root = (Logger) LogManager.getRootLogger(); CsvParameterLayoutTest.testLayoutNormalApi(root, CsvParameterLayout.createDefaultLayout(), false); }
@Test public void testLayoutTab() throws Exception { final Logger root = this.init.getRootLogger(); testLayoutNormalApi(root, CsvParameterLayout.createLayout(CSVFormat.TDF), true); }
@Override public String toSerializable(final LogEvent event) { final Message message = event.getMessage(); final Object[] parameters = message.getParameters(); final StringBuilder buffer = getStringBuilder(); try { getFormat().printRecord(buffer, parameters); return buffer.toString(); } catch (final IOException e) { StatusLogger.getLogger().error(message, e); return getFormat().getCommentMarker() + " " + e; } }
@PluginFactory public static AbstractCsvLayout createLayout( // @formatter:off @PluginConfiguration final Configuration config, @PluginAttribute(value = "format", defaultString = DEFAULT_FORMAT) final String format, @PluginAttribute("delimiter") final Character delimiter, @PluginAttribute("escape") final Character escape, @PluginAttribute("quote") final Character quote, @PluginAttribute("quoteMode") final QuoteMode quoteMode, @PluginAttribute("nullString") final String nullString, @PluginAttribute("recordSeparator") final String recordSeparator, @PluginAttribute(value = "charset", defaultString = DEFAULT_CHARSET) final Charset charset, @PluginAttribute("header") final String header, @PluginAttribute("footer") final String footer) // @formatter:on { final CSVFormat csvFormat = createFormat(format, delimiter, escape, quote, quoteMode, nullString, recordSeparator); return new CsvParameterLayout(config, charset, csvFormat, header, footer); }
public static AbstractCsvLayout createDefaultLayout() { return new CsvParameterLayout(null, Charset.forName(DEFAULT_CHARSET), CSVFormat.valueOf(DEFAULT_FORMAT), null, null); }
@Test public void testLayoutDefaultObjectArrayMessage() throws Exception { final Logger root = (Logger) LogManager.getRootLogger(); CsvParameterLayoutTest.testLayoutNormalApi(root, CsvParameterLayout.createDefaultLayout(), true); }
@Test public void testLayoutTab() throws Exception { final Logger root = (Logger) LogManager.getRootLogger(); CsvParameterLayoutTest.testLayoutNormalApi(root, CsvParameterLayout.createLayout(CSVFormat.TDF), true); } }
@Test public void testDefaultContentType() { final AbstractCsvLayout layout = CsvParameterLayout.createDefaultLayout(); assertEquals("text/csv; charset=UTF-8", layout.getContentType()); }
@Test public void testCustomCharset() { final AbstractCsvLayout layout = CsvParameterLayout.createLayout(null, "Excel", null, null, null, null, null, null, StandardCharsets.UTF_16, null, null); assertEquals("text/csv; charset=UTF-16", layout.getContentType()); }
@Test public void testLayoutDefaultNormal() throws Exception { final Logger root = this.init.getRootLogger(); testLayoutNormalApi(root, CsvParameterLayout.createDefaultLayout(), false); }
@Test public void testDefaultCharset() { final AbstractCsvLayout layout = CsvParameterLayout.createDefaultLayout(); assertEquals(StandardCharsets.UTF_8, layout.getCharset()); }
@Test public void testLayoutDefaultObjectArrayMessage() throws Exception { final Logger root = this.init.getRootLogger(); testLayoutNormalApi(root, CsvParameterLayout.createDefaultLayout(), true); }