use of java.util.logging.LogRecord in project roboguice by roboguice.
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 robovm by robovm.
the class OldFileHandlerTest method setUp.
protected void setUp() throws Exception {
super.setUp();
manager.reset();
//initProp
props.clear();
props.put("java.util.logging.FileHandler.level", "FINE");
props.put("java.util.logging.FileHandler.filter", className + "$MockFilter");
props.put("java.util.logging.FileHandler.formatter", className + "$MockFormatter");
props.put("java.util.logging.FileHandler.encoding", "iso-8859-1");
// limit to only two message
props.put("java.util.logging.FileHandler.limit", "1000");
// rotation count is 2
props.put("java.util.logging.FileHandler.count", "2");
// using append mode
props.put("java.util.logging.FileHandler.append", "true");
props.put("java.util.logging.FileHandler.pattern", "%t/log/java%u.test");
HOMEPATH = System.getProperty("user.home");
TEMPPATH = System.getProperty("java.io.tmpdir");
File file = new File(TEMPPATH + SEP + "log");
file.mkdir();
manager.readConfiguration(propertiesToInputStream(props));
handler = new FileHandler();
r = new LogRecord(Level.CONFIG, "msg");
}
use of java.util.logging.LogRecord in project robovm by robovm.
the class OldFileHandlerTest method testPublish.
public void testPublish() throws Exception {
LogRecord[] r = new LogRecord[] { new LogRecord(Level.CONFIG, "msg__"), new LogRecord(Level.WARNING, "message"), new LogRecord(Level.INFO, "message for"), new LogRecord(Level.FINE, "message for test") };
for (int i = 0; i < r.length; i++) {
handler = new FileHandler("%t/log/stringPublish");
handler.publish(r[i]);
handler.close();
assertFileContent(TEMPPATH + SEP + "log", "stringPublish", new LogRecord[] { r[i] }, handler.getFormatter());
}
}
use of java.util.logging.LogRecord in project robovm by robovm.
the class OldLogRecordTest method testGetSetTimeCheck.
public void testGetSetTimeCheck() {
long before = lr.getMillis();
try {
Thread.sleep(2);
} catch (InterruptedException e) {
e.printStackTrace();
}
LogRecord lr2 = new LogRecord(Level.CONFIG, "MSG2");
long after = lr2.getMillis();
assertTrue(after - before > 0);
}
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