@Test
public void testAppendLogData() {

  LogData data =
      FakeLogData.withPrintfStyle("Foo='%s'", "bar")
          .setTimestampNanos(123456789000L)
          .addMetadata(COUNT_KEY, 23)
          .addMetadata(ID_KEY, "test ID");
  StringBuilder b = new StringBuilder();
  LogDataFormatter.appendLogData(data, b);
  assertThat(b.toString())
      .isEqualTo(
          "  original message: Foo='%s'\n"
              + "  original arguments:\n"
              + "    bar\n"
              + "  metadata:\n"
              + "    count: 23\n"
              + "    id: test ID\n"
              + "  level: INFO\n"
              + "  timestamp (nanos): 123456789000\n"
              + "  class: com.google.FakeClass\n"
              + "  method: fakeMethod\n"
              + "  line number: 123");
}