@Test public void shouldSerializeMessageToJsonString() throws IOException { final Schema msgSchema = SchemaBuilder.struct() .field("field1", Schema.STRING_SCHEMA) .field("field2", Schema.INT32_SCHEMA) .build(); final Struct msgStruct = new Struct(msgSchema); msgStruct.put("field1", "foobar"); msgStruct.put("field2", 123); final SchemaAndValue schemaAndValue = new SchemaAndValue(msgSchema, msgStruct); logger.info(schemaAndValue); verify(innerLogger).info(any(), captor.capture()); final String asString = captor.getValue().toString(); final Object deserialized = new ObjectMapper().readValue(asString, Object.class); assertThat(deserialized, instanceOf(Map.class)); assertThat( deserialized, equalTo( ImmutableMap.of( "field1", "foobar", "field2", 123))); }
public void info(final Supplier<SchemaAndValue> msgSupplier) { if (!inner.isInfoEnabled()) { return; } info(msgSupplier.get()); }
StructuredLoggerImpl implements StructuredLogger { public void info(final Supplier<SchemaAndValue> msgSupplier) { if (!inner.isInfoEnabled()) { return; } info(msgSupplier.get()); } }
StructuredLoggerImpl implements StructuredLogger { public void info(final Supplier<SchemaAndValue> msgSupplier) { if (!inner.isInfoEnabled()) { return; } info(msgSupplier.get()); } StructuredLoggerImpl(final Logger inner); }
StructuredLoggerImpl implements StructuredLogger { public void info(final Supplier<SchemaAndValue> msgSupplier) { if (!inner.isInfoEnabled()) { return; } info(msgSupplier.get()); } StructuredLoggerImpl(final Logger inner); String getName(); void error(final Supplier<SchemaAndValue> msgSupplier); void error(final SchemaAndValue msg); void info(final Supplier<SchemaAndValue> msgSupplier); void info(final SchemaAndValue msg); void debug(final Supplier<SchemaAndValue> msgSupplier); void debug(final SchemaAndValue msg); }
StructuredLoggerImpl implements StructuredLogger { public void info(final Supplier<SchemaAndValue> msgSupplier) { if (!inner.isInfoEnabled()) { return; } info(msgSupplier.get()); } StructuredLoggerImpl(final Logger inner); String getName(); void error(final Supplier<SchemaAndValue> msgSupplier); void error(final SchemaAndValue msg); void info(final Supplier<SchemaAndValue> msgSupplier); void info(final SchemaAndValue msg); void debug(final Supplier<SchemaAndValue> msgSupplier); void debug(final SchemaAndValue msg);  }