Java 类org.apache.logging.log4j.message.FormattedMessage 实例源码

项目:EnderCore    文件:TextureErrorRemover.java   
@Override
public void log(Marker marker, String fqcn, Level level, Message data, Throwable t) {
  if (ConfigHandler.textureErrorRemover != 0) {
    if (t instanceof FileNotFoundException) {
      if (ConfigHandler.textureErrorRemover == 1) {
        super.log(marker, fqcn, level, data, null);
      }
      removed++;
    } else {
      super.log(marker, fqcn, level, data, t);
    }
    if (data.getFormat().startsWith("Created:")) {
      EnderCore.logger.info(ConfigHandler.textureErrorRemover == 1 ? new FormattedMessage("Removed %d missing texture stacktraces. Tada!", removed)
          : new FormattedMessage("There were %d missing texture errors here. They're gone now.", removed));
      removed = 0;
    }
    return;
  }
  super.log(marker, fqcn, level, data, t);
}
项目:logging-log4j2    文件:LoggerSupplierTest.java   
@Test
public void flowTracing_SupplierOfFormattedMessage() {
    logger.traceEntry(new Supplier<FormattedMessage>() {
        @Override
        public FormattedMessage get() {
            return new FormattedMessage("int foo={}", 1234567890);
        }
    });
    assertEquals(1, results.size());
    assertThat("Incorrect Entry", results.get(0), startsWith("ENTER[ FLOW ] TRACE Enter"));
    assertThat("Missing entry data", results.get(0), containsString("(int foo=1234567890)"));
    assertThat("Bad toString()", results.get(0), not(containsString("FormattedMessage")));
}