@Test public void shouldThrowIfInvalidParameterType() { expectInvalidParameters(123); layout.toByteArray(logEvent); }
public byte[] toByteArray(final LogEvent event) { if (event.getMessage().getParameters().length != 1 || !(event.getMessage().getParameters()[0] instanceof StructuredLogMessage)) { throw new IllegalArgumentException( "LogEvent must contain a single parameter of type StructuredLogMessage"); } final StructuredLogMessage schemaAndValue = (StructuredLogMessage) event.getMessage().getParameters()[0]; final Struct logRecord = logRecordStructBuilderFactory.get() .withLoggerName(event.getLoggerName()) .withLevel(event.getLevel().name()) .withTimeMs(event.getTimeMillis()) .withMessageSchemaAndValue(schemaAndValue.getMessage()) .build(); return serializer.apply(logRecord); }
StructuredLayout extends AbstractLayout<byte[]> { public byte[] toByteArray(final LogEvent event) { if (event.getMessage().getParameters().length != 1 || !(event.getMessage().getParameters()[0] instanceof StructuredLogMessage)) { throw new IllegalArgumentException( "LogEvent must contain a single parameter of type StructuredLogMessage"); } final StructuredLogMessage schemaAndValue = (StructuredLogMessage) event.getMessage().getParameters()[0]; final Struct logRecord = logRecordStructBuilderFactory.get() .withLoggerName(event.getLoggerName()) .withLevel(event.getLevel().name()) .withTimeMs(event.getTimeMillis()) .withMessageSchemaAndValue(schemaAndValue.getMessage()) .build(); return serializer.apply(logRecord); } }
StructuredLayout extends AbstractLayout<byte[]> { public byte[] toByteArray(final LogEvent event) { if (event.getMessage().getParameters().length != 1 || !(event.getMessage().getParameters()[0] instanceof StructuredLogMessage)) { throw new IllegalArgumentException( "LogEvent must contain a single parameter of type StructuredLogMessage"); } final StructuredLogMessage schemaAndValue = (StructuredLogMessage) event.getMessage().getParameters()[0]; final Struct logRecord = logRecordStructBuilderFactory.get() .withLoggerName(event.getLoggerName()) .withLevel(event.getLevel().name()) .withTimeMs(event.getTimeMillis()) .withMessageSchemaAndValue(schemaAndValue.getMessage()) .build(); return serializer.apply(logRecord); } StructuredLayout(final Function<Struct, byte[]> serializer);   StructuredLayout(
      final Function<Struct, byte[]> serializer,
      final Supplier<LogRecordBuilder<Struct>> logRecordBuilderFactory); }
StructuredLayout extends AbstractLayout<byte[]> { public byte[] toByteArray(final LogEvent event) { if (event.getMessage().getParameters().length != 1 || !(event.getMessage().getParameters()[0] instanceof StructuredLogMessage)) { throw new IllegalArgumentException( "LogEvent must contain a single parameter of type StructuredLogMessage"); } final StructuredLogMessage schemaAndValue = (StructuredLogMessage) event.getMessage().getParameters()[0]; final Struct logRecord = logRecordStructBuilderFactory.get() .withLoggerName(event.getLoggerName()) .withLevel(event.getLevel().name()) .withTimeMs(event.getTimeMillis()) .withMessageSchemaAndValue(schemaAndValue.getMessage()) .build(); return serializer.apply(logRecord); } StructuredLayout(final Function<Struct, byte[]> serializer);   StructuredLayout(
      final Function<Struct, byte[]> serializer,
      final Supplier<LogRecordBuilder<Struct>> logRecordBuilderFactory); byte[] toByteArray(final LogEvent event); String getContentType(); byte[] toSerializable(final LogEvent event); }
StructuredLayout extends AbstractLayout<byte[]> { public byte[] toByteArray(final LogEvent event) { if (event.getMessage().getParameters().length != 1 || !(event.getMessage().getParameters()[0] instanceof StructuredLogMessage)) { throw new IllegalArgumentException( "LogEvent must contain a single parameter of type StructuredLogMessage"); } final StructuredLogMessage schemaAndValue = (StructuredLogMessage) event.getMessage().getParameters()[0]; final Struct logRecord = logRecordStructBuilderFactory.get() .withLoggerName(event.getLoggerName()) .withLevel(event.getLevel().name()) .withTimeMs(event.getTimeMillis()) .withMessageSchemaAndValue(schemaAndValue.getMessage()) .build(); return serializer.apply(logRecord); } StructuredLayout(final Function<Struct, byte[]> serializer);   StructuredLayout(
      final Function<Struct, byte[]> serializer,
      final Supplier<LogRecordBuilder<Struct>> logRecordBuilderFactory); byte[] toByteArray(final LogEvent event); String getContentType(); byte[] toSerializable(final LogEvent event);  }