/** * Logs based on the parameters given. Uses the format parameter inside * {@link MessageFormat}. * * @param level * the logging level at which to write the message. * @param ex * [optional] exception stack trace to log. * @param format * [optional] create a message of a particular format. * @param args * [optional] parameters to the format string. */ public void log(final Level level, final Throwable ex, final String format, final Object... args) { if (isLoggable(level)) { String message = format; if (format != null && args != null) { // consider using thread local pattern to cache these for // performance the pattern will always may always changed. message = MessageFormat.format(format, args); } else if (format == null && ex != null) { message = ex.getLocalizedMessage(); } String methodName = ReflectionUtil.getMethodName(3); log(_clazz, methodName, level, message, ex); } }
@Test public void testGetMethodName() { String actual = ReflectionUtil.getMethodName(1); assertEquals(actual, "testGetMethodName"); } }