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 flyway by flyway.
the class JavaUtilLog method log.
/**
* Log the message at the specified level with the specified exception if any.
*
* @param level The level to log at.
* @param message The message to log.
* @param e The exception, if any.
*/
private void log(Level level, String message, Exception e) {
// millis and thread are filled by the constructor
LogRecord record = new LogRecord(level, message);
record.setLoggerName(logger.getName());
record.setThrown(e);
record.setSourceClassName(logger.getName());
record.setSourceMethodName(getMethodName());
logger.log(record);
}
use of java.util.logging.LogRecord in project guava by hceylan.
the class TestLogHandlerTest method test.
public void test() throws Exception {
assertTrue(handler.getStoredLogRecords().isEmpty());
ExampleClassUnderTest.foo();
LogRecord record = handler.getStoredLogRecords().iterator().next();
assertEquals(Level.INFO, record.getLevel());
assertEquals("message", record.getMessage());
assertSame(EXCEPTION, record.getThrown());
}
use of java.util.logging.LogRecord in project j2objc by google.
the class LoggerTest method testSevere_Null.
/*
* Test severe(String) with null values.
*/
public void testSevere_Null() {
Logger child = new MockLogger("childLogger", null);
Logger parent = new MockLogger("parentLogger", VALID_RESOURCE_BUNDLE2);
child.addHandler(new MockHandler());
child.setParent(parent);
child.setLevel(Level.SEVERE);
child.severe(null);
LogRecord r = (LogRecord) CallVerificationStack.getInstance().pop();
assertTrue(CallVerificationStack.getInstance().empty());
assertSame(r.getLoggerName(), child.getName());
assertNull(r.getMessage());
assertSame(r.getResourceBundleName(), parent.getResourceBundleName());
assertSame(r.getResourceBundle(), parent.getResourceBundle());
assertSame(r.getSourceClassName(), null);
assertSame(r.getSourceMethodName(), null);
assertSame(r.getLevel(), Level.SEVERE);
assertNull(r.getParameters());
assertSame(r.getThrown(), null);
this.sharedLogger.setLevel(Level.OFF);
this.sharedLogger.severe(null);
assertTrue(CallVerificationStack.getInstance().empty());
}
use of java.util.logging.LogRecord in project j2objc by google.
the class LoggerTest method testLogrb_LevelStringTStringStringhrowable_NullMsgObj.
/*
* Test logrb(Level, String, String, String, String, Throwable) with null
* message and throwable.
*/
public void testLogrb_LevelStringTStringStringhrowable_NullMsgObj() {
this.sharedLogger.setLevel(Level.INFO);
this.sharedLogger.logrb(Level.INFO, null, null, null, null, (Throwable) null);
LogRecord r = (LogRecord) CallVerificationStack.getInstance().pop();
assertTrue(CallVerificationStack.getInstance().empty());
assertSame(r.getLoggerName(), this.sharedLogger.getName());
assertNull(r.getMessage());
assertSame(r.getResourceBundleName(), null);
assertSame(r.getSourceClassName(), null);
assertSame(r.getSourceMethodName(), null);
assertSame(r.getLevel(), Level.INFO);
assertNull(r.getParameters());
assertSame(r.getThrown(), null);
}
Aggregations