class 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);

}