use of java.util.logging.LogRecord in project generator by mybatis.
the class JdkLoggingImpl method error.
public void error(String s, Throwable e) {
LogRecord lr = new LogRecord(Level.SEVERE, s);
lr.setSourceClassName(log.getName());
lr.setThrown(e);
log.log(lr);
}
use of java.util.logging.LogRecord in project netty by netty.
the class JdkLogger method log.
/**
* Log the message at the specified level with the specified throwable if any.
* This method creates a LogRecord and fills in caller date before calling
* this instance's JDK14 logger.
*
* See bug report #13 for more details.
*/
private void log(String callerFQCN, Level level, String msg, Throwable t) {
// millis and thread are filled by the constructor
LogRecord record = new LogRecord(level, msg);
record.setLoggerName(name());
record.setThrown(t);
fillCallerData(callerFQCN, record);
logger.log(record);
}
use of java.util.logging.LogRecord in project randomizedtesting by randomizedtesting.
the class WithNestedTestClass method setupNested.
@BeforeClass
public static final void setupNested() throws IOException {
runningNested = true;
zombieToken = new Object();
// capture sysout/ syserr.
sw = new StringWriter();
sysout = System.out;
syserr = System.err;
System.setOut(new PrintStream(new TeeOutputStream(System.out, new WriterOutputStream(sw))));
System.setErr(new PrintStream(new TeeOutputStream(System.err, new WriterOutputStream(sw))));
// Add custom logging handler because java logging keeps a reference to previous System.err.
loggingMessages = new StringWriter();
logger = Logger.getLogger("");
handlers = logger.getHandlers();
for (Handler h : handlers) logger.removeHandler(h);
logger.addHandler(new Handler() {
final SimpleFormatter formatter = new SimpleFormatter();
@Override
public void publish(LogRecord record) {
loggingMessages.write(formatter.format(record) + "\n");
}
@Override
public void flush() {
}
@Override
public void close() throws SecurityException {
}
});
}
use of java.util.logging.LogRecord in project byte-buddy by raphw.
the class ByteBuddyLogHandlerTest method testLogPublishDebug.
@Test
public void testLogPublishDebug() throws Exception {
ByteBuddyLogHandler byteBuddyLogHandler = new ByteBuddyLogHandler(log, mock(Logger.class), false);
LogRecord logRecord = new LogRecord(Level.INFO, FOO);
when(log.isDebugEnabled()).thenReturn(true);
byteBuddyLogHandler.publish(logRecord);
verify(log).isDebugEnabled();
verify(log).debug(byteBuddyLogHandler.getFormatter().format(logRecord));
verifyNoMoreInteractions(log);
}
use of java.util.logging.LogRecord in project byte-buddy by raphw.
the class ByteBuddyLogHandlerTest method testLogPublishNoDebug.
@Test
public void testLogPublishNoDebug() throws Exception {
ByteBuddyLogHandler byteBuddyLogHandler = new ByteBuddyLogHandler(log, mock(Logger.class), false);
LogRecord logRecord = new LogRecord(Level.INFO, FOO);
byteBuddyLogHandler.publish(logRecord);
verify(log).isDebugEnabled();
verifyNoMoreInteractions(log);
}
Aggregations