@Test public void testFormat_pretty() { OptionalFields credentials = OptionalFields .builder() .setStringValue("username") .setBinaryValue(Binary.fromBase64("password")) .build(); LogFormatter formatter = new LogFormatter(true, (writer, field, value) -> { if (field.getName() .contains("binary")) { writer.append("\"********\""); return true; } return false; }); assertThat(formatter.format(credentials), is("providence.OptionalFields {\n" + " stringValue = \"username\"\n" + " binaryValue = \"********\"\n" + "}")); }
public <Message extends PMessage<Message, Field>, Field extends PField> String format(Message message) { ByteArrayOutputStream out = new ByteArrayOutputStream(); formatTo(out, message); return new String(out.toByteArray(), StandardCharsets.UTF_8); }
LogFormatter { public <Message extends PMessage<Message, Field>, Field extends PField> String format(Message message) { ByteArrayOutputStream out = new ByteArrayOutputStream(); formatTo(out, message); return new String(out.toByteArray(), StandardCharsets.UTF_8); } }
LogFormatter { public <Message extends PMessage<Message, Field>, Field extends PField> String format(Message message) { ByteArrayOutputStream out = new ByteArrayOutputStream(); formatTo(out, message); return new String(out.toByteArray(), StandardCharsets.UTF_8); } LogFormatter(FieldHandler... fieldHandlers);  LogFormatter(boolean pretty, FieldHandler... fieldHandlers);  LogFormatter(boolean pretty, Collection<FieldHandler> fieldHandlers); }
LogFormatter { public <Message extends PMessage<Message, Field>, Field extends PField> String format(Message message) { ByteArrayOutputStream out = new ByteArrayOutputStream(); formatTo(out, message); return new String(out.toByteArray(), StandardCharsets.UTF_8); } LogFormatter(FieldHandler... fieldHandlers);  LogFormatter(boolean pretty, FieldHandler... fieldHandlers);  LogFormatter(boolean pretty, Collection<FieldHandler> fieldHandlers); void formatTo(OutputStream out, Message message); String format(Message message); }
LogFormatter { public <Message extends PMessage<Message, Field>, Field extends PField> String format(Message message) { ByteArrayOutputStream out = new ByteArrayOutputStream(); formatTo(out, message); return new String(out.toByteArray(), StandardCharsets.UTF_8); } LogFormatter(FieldHandler... fieldHandlers);  LogFormatter(boolean pretty, FieldHandler... fieldHandlers);  LogFormatter(boolean pretty, Collection<FieldHandler> fieldHandlers); void formatTo(OutputStream out, Message message); String format(Message message);  }