/** * Log a message to the logger of the caller at the given offset in the stack trace. * * If <code>A.f()</code> calls <code>B.g()</code> that finally calls <code>dynamicLog(1, msg)</code> then, the msg * will be logged with a code similar to: <br> * <code>getLogger(B.getClass().getName()).log(level, msg);</code><br> * * If the call was <code>dynamicLog(2, msg)</code> then, the code would be:<br> * <code>getLogger(A.getClass().getName()).log(level, msg);</code><br> * * @param offset * the offset in the stack trace * @param level * the level to log the message to * @param msg * the message to log */ public static void dynamicLog(final int offset, final Level level, final String msg) { final StackTraceElement callerSTE = Misc.getCaller(offset); final String className = callerSTE.getClassName(); final String methodName = callerSTE.getMethodName(); final Logger logger = Logger.getLogger(className); final LogRecord record = new LogRecord(level, msg); record.setSourceClassName(className); record.setSourceMethodName(methodName); record.setLoggerName(logger.getName()); logger.log(record); }
/** * Log a message to the logger of the caller at the given offset in the stack trace. * * If <code>A.f()</code> calls <code>B.g()</code> that finally calls <code>dynamicLog(1, msg)</code> then, the msg * will be logged with a code similar to: <br> * <code>getLogger(B.getClass().getName()).log(level, msg);</code><br> * * If the call was <code>dynamicLog(2, msg)</code> then, the code would be:<br> * <code>getLogger(A.getClass().getName()).log(level, msg);</code><br> * * @param offset * the offset in the stack trace * @param level * the level to log the message to * @param msg * the message to log */ public static void dynamicLog(final int offset, final Level level, final String msg) { final StackTraceElement callerSTE = Misc.getCaller(offset); final String className = callerSTE.getClassName(); final String methodName = callerSTE.getMethodName(); final Logger logger = Logger.getLogger(className); final LogRecord record = new LogRecord(level, msg); record.setSourceClassName(className); record.setSourceMethodName(methodName); record.setLoggerName(logger.getName()); logger.log(record); }
/** * Log a message to the logger of the caller at the given offset in the stack * trace. * * If <code>A.f()</code> calls <code>B.g()</code> that finally calls * <code>dynamicLog(1, msg)</code> then, the msg will be logged with a code * similar to: <br> * <code>getLogger(B.getClass().getName()).log(level, msg);</code><br> * * If the call was <code>dynamicLog(2, msg)</code> then, the code would be:<br> * <code>getLogger(A.getClass().getName()).log(level, msg);</code><br> * * * @param offset the offset in the stack trace * @param level the level to log the message to * @param msg the message to log * @return */ public static void dynamicLog(final int offset, final Level level, final String msg) { final StackTraceElement callerSTE = Misc.getCaller(offset); final String className = callerSTE.getClassName(); final String methodName = callerSTE.getMethodName(); final Logger logger = Logger.getLogger(className); final LogRecord record = new LogRecord(level, msg); record.setSourceClassName(className); record.setSourceMethodName(methodName); record.setLoggerName(logger.getName()); logger.log(record); }
if (result.hasNull()) { final StackTraceElement callerSTE = Misc.getCaller(offset + 1); final String className = callerSTE.getClassName(); final String methodName = callerSTE.getMethodName();
if (result.hasNull()) { final StackTraceElement callerSTE = Misc.getCaller(offset + 1); final String className = callerSTE.getClassName(); final String methodName = callerSTE.getMethodName();
if (result.hasNull()) { final StackTraceElement callerSTE = Misc.getCaller(offset + 1); final String className = callerSTE.getClassName(); final String methodName = callerSTE.getMethodName();