use of java.util.logging.LogRecord in project j2objc by google.
the class LoggerTest method testInfo_Normal.
/*
* Test info(String) with normal values.
*/
public void testInfo_Normal() {
this.sharedLogger.setLevel(Level.INFO);
this.sharedLogger.info("info msg");
LogRecord r = (LogRecord) CallVerificationStack.getInstance().pop();
assertTrue(CallVerificationStack.getInstance().empty());
assertSame(r.getLoggerName(), this.sharedLogger.getName());
assertEquals(r.getMessage(), "info msg");
assertSame(r.getResourceBundleName(), this.sharedLogger.getResourceBundleName());
assertSame(r.getResourceBundle(), this.sharedLogger.getResourceBundle());
assertSame(r.getSourceClassName(), null);
assertSame(r.getSourceMethodName(), null);
assertSame(r.getLevel(), Level.INFO);
assertNull(r.getParameters());
assertSame(r.getThrown(), null);
this.sharedLogger.setLevel(Level.WARNING);
this.sharedLogger.info("info again");
assertTrue(CallVerificationStack.getInstance().empty());
}
use of java.util.logging.LogRecord in project j2objc by google.
the class LoggerTest method testLog_LogRecord_InppropriateLevelNoFilterNoParent.
/*
* Test log(LogRecord) for a normal log record. Meanwhile the logger has an
* inappropriate level, no filter, no parent.
*/
public void testLog_LogRecord_InppropriateLevelNoFilterNoParent() {
LogRecord r = new LogRecord(Level.INFO, "testLog_LogRecord_InppropriateLevelNoFilterNoParent");
this.sharedLogger.setLevel(Level.WARNING);
this.sharedLogger.log(r);
assertTrue(CallVerificationStack.getInstance().empty());
r.setLevel(Level.OFF);
this.sharedLogger.setLevel(Level.OFF);
this.sharedLogger.log(r);
assertTrue(CallVerificationStack.getInstance().empty());
}
use of java.util.logging.LogRecord in project guava by google.
the class CloserTest method testLoggingSuppressor.
public static void testLoggingSuppressor() throws IOException {
TestLogHandler logHandler = new TestLogHandler();
Closeables.logger.addHandler(logHandler);
try {
Closer closer = new Closer(new Closer.LoggingSuppressor());
TestCloseable c1 = closer.register(TestCloseable.throwsOnClose(new IOException()));
TestCloseable c2 = closer.register(TestCloseable.throwsOnClose(new RuntimeException()));
try {
throw closer.rethrow(new IOException("thrown"), IOException.class);
} catch (IOException expected) {
}
assertTrue(logHandler.getStoredLogRecords().isEmpty());
closer.close();
assertEquals(2, logHandler.getStoredLogRecords().size());
LogRecord record = logHandler.getStoredLogRecords().get(0);
assertEquals("Suppressing exception thrown when closing " + c2, record.getMessage());
record = logHandler.getStoredLogRecords().get(1);
assertEquals("Suppressing exception thrown when closing " + c1, record.getMessage());
} finally {
Closeables.logger.removeHandler(logHandler);
}
}
use of java.util.logging.LogRecord in project guice by google.
the class BinderTest method testUserReportedErrorsAreAlsoLogged.
public void testUserReportedErrorsAreAlsoLogged() {
try {
Guice.createInjector(new AbstractModule() {
@Override
protected void configure() {
addError(new Message("Whoops!", new IllegalArgumentException()));
}
});
fail();
} catch (CreationException expected) {
}
LogRecord logRecord = Iterables.getOnlyElement(this.logRecords);
assertContains(logRecord.getMessage(), "An exception was caught and reported. Message: java.lang.IllegalArgumentException");
}
use of java.util.logging.LogRecord in project liquibase by liquibase.
the class LiquibaseStatusServlet method doGet.
@Override
protected void doGet(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse) throws ServletException, IOException {
httpServletResponse.setContentType("text/html");
String logLevelToDisplay = httpServletRequest.getParameter("logLevel");
Level currentLevel = Level.INFO;
if (logLevelToDisplay != null) {
currentLevel = Level.parse(logLevelToDisplay);
}
PrintWriter writer = httpServletResponse.getWriter();
writer.println("<html>");
writer.println("<head><title>Liquibase Status</title></head>");
writer.println("<body>");
if (liquibaseRunLog.size() == 0) {
writer.println("<b>Liquibase did not run</b>");
} else {
writer.println("<b>View level: " + getLevelLink(Level.SEVERE, currentLevel, httpServletRequest) + " " + getLevelLink(Level.WARNING, currentLevel, httpServletRequest) + " " + getLevelLink(Level.INFO, currentLevel, httpServletRequest) + " " + getLevelLink(Level.CONFIG, currentLevel, httpServletRequest) + " " + getLevelLink(Level.FINE, currentLevel, httpServletRequest) + " " + getLevelLink(Level.FINER, currentLevel, httpServletRequest) + " " + getLevelLink(Level.FINEST, currentLevel, httpServletRequest) + "</b>");
writer.println("<hr>");
writer.println("<b>Liquibase started at " + DateFormat.getDateTimeInstance().format(new Date(liquibaseRunLog.get(0).getMillis())));
writer.println("<hr>");
writer.println("<pre>");
for (LogRecord record : liquibaseRunLog) {
if (record.getLevel().intValue() >= currentLevel.intValue()) {
writer.println(record.getLevel() + ": " + record.getMessage());
if (record.getThrown() != null) {
record.getThrown().printStackTrace(writer);
}
}
}
writer.println("");
writer.println("");
writer.println("</pre>");
writer.println("<hr>");
writer.println("<b>Liquibase finished at " + DateFormat.getDateTimeInstance().format(new Date(liquibaseRunLog.get(liquibaseRunLog.size() - 1).getMillis())));
}
writer.println("</body>");
writer.println("</html>");
}
Aggregations