@Test public void testLog() throws Exception { Logger logger = createNiceMock(Logger.class); SessionLogEntry severeEntry = createNiceMock(SessionLogEntry.class); SessionLogEntry configEntry = createNiceMock(SessionLogEntry.class); SessionLogEntry finestEntry = createNiceMock(SessionLogEntry.class); Formatter formatter = createNiceMock(Formatter.class); JpaLogger jpaLogger = new TestJpaLogger(logger, formatter); expect(severeEntry.getLevel()).andReturn(SessionLog.SEVERE); expect(formatter.format((LogRecord) anyObject())).andReturn("severe log message"); logger.error("severe log message"); expect(configEntry.getLevel()).andReturn(SessionLog.CONFIG); expect(formatter.format((LogRecord) anyObject())).andReturn("config log message"); logger.info("config log message"); expect(finestEntry.getLevel()).andReturn(SessionLog.FINEST); expect(formatter.format((LogRecord) anyObject())).andReturn("finest log message"); logger.debug("finest log message"); replay(logger, severeEntry, configEntry, finestEntry, formatter); jpaLogger.log(severeEntry); jpaLogger.log(configEntry); jpaLogger.log(finestEntry); verify(logger, severeEntry, configEntry, finestEntry, formatter); }
@Override public void log(SessionLogEntry sessionLogEntry) { Logger logger = getLogger(); switch (sessionLogEntry.getLevel()) { case SEVERE: logger.error(getLogMessage(sessionLogEntry)); break; case WARNING: logger.warn(getLogMessage(sessionLogEntry)); break; case INFO: case CONFIG: logger.info(getLogMessage(sessionLogEntry)); break; case FINE: case FINER: case FINEST: logger.debug(getLogMessage(sessionLogEntry)); break; case ALL: logger.trace(getLogMessage(sessionLogEntry)); break; } }
JpaLogger extends AbstractSessionLog { @Override public void log(SessionLogEntry sessionLogEntry) { Logger logger = getLogger(); switch (sessionLogEntry.getLevel()) { case SEVERE: logger.error(getLogMessage(sessionLogEntry)); break; case WARNING: logger.warn(getLogMessage(sessionLogEntry)); break; case INFO: case CONFIG: logger.info(getLogMessage(sessionLogEntry)); break; case FINE: case FINER: case FINEST: logger.debug(getLogMessage(sessionLogEntry)); break; case ALL: logger.trace(getLogMessage(sessionLogEntry)); break; } } }
JpaLogger extends AbstractSessionLog { @Override public void log(SessionLogEntry sessionLogEntry) { Logger logger = getLogger(); switch (sessionLogEntry.getLevel()) { case SEVERE: logger.error(getLogMessage(sessionLogEntry)); break; case WARNING: logger.warn(getLogMessage(sessionLogEntry)); break; case INFO: case CONFIG: logger.info(getLogMessage(sessionLogEntry)); break; case FINE: case FINER: case FINEST: logger.debug(getLogMessage(sessionLogEntry)); break; case ALL: logger.trace(getLogMessage(sessionLogEntry)); break; } }  }
JpaLogger extends AbstractSessionLog { @Override public void log(SessionLogEntry sessionLogEntry) { Logger logger = getLogger(); switch (sessionLogEntry.getLevel()) { case SEVERE: logger.error(getLogMessage(sessionLogEntry)); break; case WARNING: logger.warn(getLogMessage(sessionLogEntry)); break; case INFO: case CONFIG: logger.info(getLogMessage(sessionLogEntry)); break; case FINE: case FINER: case FINEST: logger.debug(getLogMessage(sessionLogEntry)); break; case ALL: logger.trace(getLogMessage(sessionLogEntry)); break; } }  @Override void log(SessionLogEntry sessionLogEntry); @Override void throwing(Throwable throwable); @Override boolean shouldLog(int level, String category); Level getLogLevel(); void setLogLevel(Level logLevel); }
JpaLogger extends AbstractSessionLog { @Override public void log(SessionLogEntry sessionLogEntry) { Logger logger = getLogger(); switch (sessionLogEntry.getLevel()) { case SEVERE: logger.error(getLogMessage(sessionLogEntry)); break; case WARNING: logger.warn(getLogMessage(sessionLogEntry)); break; case INFO: case CONFIG: logger.info(getLogMessage(sessionLogEntry)); break; case FINE: case FINER: case FINEST: logger.debug(getLogMessage(sessionLogEntry)); break; case ALL: logger.trace(getLogMessage(sessionLogEntry)); break; } }  @Override void log(SessionLogEntry sessionLogEntry); @Override void throwing(Throwable throwable); @Override boolean shouldLog(int level, String category); Level getLogLevel(); void setLogLevel(Level logLevel); public Level logLevel; static final Level[] JAVA_LOG_LEVELS; }