/** * Logs a return from method. * <p> * This method can be used to log return from a method. A {@link LogRecord} with message * "RETURN" and the given {@code sourceMethod} and {@code sourceClass} is logged with * {@link Level#FINER finer level}. * * @param sourceClass the exiting class * @param sourceMethod the exiting method * @since 1.0 */ public void exiting(final String sourceClass, final String sourceMethod) { logp(Level.FINER, sourceClass, sourceMethod, "RETURN"); }
/** * Logs entry into method. * <p> * This method can be used to log entry into a method. A {@link LogRecord} with message "ENTRY" * and the given {@code sourceMethod} and {@code sourceClass} is logged with {@link Level#FINER * finer level}. * * @param sourceClass the entered class * @param sourceMethod the entered method * @since 1.0 */ public void entering(final String sourceClass, final String sourceMethod) { logp(Level.FINER, sourceClass, sourceMethod, "ENTRY"); }
/** * Logs entry into method with single parameter. * <p> * This method can be used to log entry into a method. A {@link LogRecord} with message "ENTRY", * the given {@code sourceMethod} and {@code sourceClass} and given parameter is logged with * {@link Level#FINER finer level}. * * @param sourceClass the entered class * @param sourceMethod the entered method * @param parameter the method parameter * @since 1.0 */ public void entering(final String sourceClass, final String sourceMethod, final Object parameter) { logp(Level.FINER, sourceClass, sourceMethod, "ENTRY {0}", parameter); }
/** * Logs a return from method with result. * <p> * This method can be used to log return from a method. A {@link LogRecord} with message * "RETURN", the given {@code sourceMethod} and {@code sourceClass} and method result is logged * with {@link Level#FINER finer level}. * * @param sourceClass the exiting class * @param sourceMethod the exiting method * @param result the return value * @since 1.0 */ public void exiting(final String sourceClass, final String sourceMethod, final Object result) { logp(Level.FINER, sourceClass, sourceMethod, "RETURN {0}", result); }
/** * Logs throwing an exception. * <p> * This method can be used to log exception thrown from a method. A {@link LogRecord} with * message "THROW",the given {@code sourceMethod} and {@code sourceClass} and {@code thrown} is * logged with {@link Level#FINER finer level}. * * @param sourceClass the class throwing an exception * @param sourceMethod the method throwing an exception * @param thrown the thrown exception * @since 1.0 */ public <T extends Throwable> T throwing(final String sourceClass, final String sourceMethod, final T thrown) { logp(Level.FINER, sourceClass, sourceMethod, "THROW", thrown); return thrown; }
/** * Logs entry into method with multiple parameters. * <p> * This method can be used to log entry into a method. A {@link LogRecord} with message "ENTRY", * the given {@code sourceMethod} and {@code sourceClass} and given parameters is logged with * {@link Level#FINER finer level}. * * @param sourceClass the entered class * @param sourceMethod the entered method * @param parameters the method parameters * @since 1.0 */ public void entering(final String sourceClass, final String sourceMethod, final Object[] parameters) { String msg = "ENTRY"; if (parameters == null) { logp(Level.FINER, sourceClass, sourceMethod, msg); return; } if (!isLoggable(Level.FINER)) { return; } for (int i = 0; i < parameters.length; i++) { msg = msg + " {" + i + "}"; } logp(Level.FINER, sourceClass, sourceMethod, msg, parameters); }