类org.apache.velocity.runtime.log.JdkLogChute源码实例Demo

下面列出了怎么用org.apache.velocity.runtime.log.JdkLogChute的API类实例代码及写法,或者点击链接到github查看源代码。

源代码1 项目: RetroFacebook   文件: NoVelocityLoggingTest.java
private void doTestDontLog(File log) throws IOException {
  // Set things up so that if Velocity is successfully logging then we will see its log output
  // in the temporary file we have created. This depends on Velocity falling back on JDK logging,
  // so this test won't do anything useful if its classpath contains Log4J or Commons Logging or
  // any of the other exotic logging systems that Velocity will pounce on if it sees them.
  FileHandler fileHandler = new FileHandler(log.getPath());
  fileHandler.setFormatter(new SimpleFormatter());
  Logger logger = Logger.getLogger(JdkLogChute.DEFAULT_LOG_NAME);
  logger.addHandler(fileHandler);
  logger.setLevel(Level.ALL);
  LogManager logManager = LogManager.getLogManager();
  logManager.addLogger(logger);

  // Now do a random compilation that implies using RetroFacebookProcessor.
  JavaFileObject javaFileObject = JavaFileObjects.forSourceLines(
      "foo.bar.Baz",
      "package foo.bar;",
      "",
      "import retrofacebook.RetroFacebook;",
      "",
      "@RetroFacebook",
      "public abstract class Baz {",
      "  public abstract int buh();",
      "",
      "  public static Baz create(int buh) {",
      "    return new RetroFacebook_Baz(buh);",
      "  }",
      "}");
  assert_().about(javaSource())
      .that(javaFileObject)
      .processedWith(new RetroFacebookProcessor())
      .compilesWithoutError();

  // The log file should be empty.
  fileHandler.close();
  assertEquals("", Files.toString(log, StandardCharsets.UTF_8));
}
 
源代码2 项目: RetroFacebook   文件: NoVelocityLoggingTest.java
private void doTestDontLog(File log) throws IOException {
  // Set things up so that if Velocity is successfully logging then we will see its log output
  // in the temporary file we have created. This depends on Velocity falling back on JDK logging,
  // so this test won't do anything useful if its classpath contains Log4J or Commons Logging or
  // any of the other exotic logging systems that Velocity will pounce on if it sees them.
  FileHandler fileHandler = new FileHandler(log.getPath());
  fileHandler.setFormatter(new SimpleFormatter());
  Logger logger = Logger.getLogger(JdkLogChute.DEFAULT_LOG_NAME);
  logger.addHandler(fileHandler);
  logger.setLevel(Level.ALL);
  LogManager logManager = LogManager.getLogManager();
  logManager.addLogger(logger);

  // Now do a random compilation that implies using RetroFacebookProcessor.
  JavaFileObject javaFileObject = JavaFileObjects.forSourceLines(
      "foo.bar.Baz",
      "package foo.bar;",
      "",
      "import retrofacebook.RetroFacebook;",
      "",
      "@RetroFacebook",
      "public abstract class Baz {",
      "  public abstract int buh();",
      "",
      "  public static Baz create(int buh) {",
      "    return new RetroFacebook_Baz(buh);",
      "  }",
      "}");
  assert_().about(javaSource())
      .that(javaFileObject)
      .processedWith(new RetroFacebookProcessor())
      .compilesWithoutError();

  // The log file should be empty.
  fileHandler.close();
  assertEquals("", Files.toString(log, StandardCharsets.UTF_8));
}
 
源代码3 项目: SimpleWeibo   文件: NoVelocityLoggingTest.java
private void doTestDontLog(File log) throws IOException {
  // Set things up so that if Velocity is successfully logging then we will see its log output
  // in the temporary file we have created. This depends on Velocity falling back on JDK logging,
  // so this test won't do anything useful if its classpath contains Log4J or Commons Logging or
  // any of the other exotic logging systems that Velocity will pounce on if it sees them.
  FileHandler fileHandler = new FileHandler(log.getPath());
  fileHandler.setFormatter(new SimpleFormatter());
  Logger logger = Logger.getLogger(JdkLogChute.DEFAULT_LOG_NAME);
  logger.addHandler(fileHandler);
  logger.setLevel(Level.ALL);
  LogManager logManager = LogManager.getLogManager();
  logManager.addLogger(logger);

  // Now do a random compilation that implies using RetroWeiboProcessor.
  JavaFileObject javaFileObject = JavaFileObjects.forSourceLines(
      "foo.bar.Baz",
      "package foo.bar;",
      "",
      "import retroweibo.RetroWeibo;",
      "",
      "@RetroWeibo",
      "public abstract class Baz {",
      "  public abstract int buh();",
      "",
      "  public static Baz create(int buh) {",
      "    return new RetroWeibo_Baz(buh);",
      "  }",
      "}");
  assert_().about(javaSource())
      .that(javaFileObject)
      .processedWith(new RetroWeiboProcessor())
      .compilesWithoutError();

  // The log file should be empty.
  fileHandler.close();
  assertEquals("", Files.toString(log, StandardCharsets.UTF_8));
}
 
 类所在包
 类方法
 同包方法