You are viewing a plain text version of this content. The canonical link for it is here.
Posted to log4j-dev@logging.apache.org by ca...@apache.org on 2008/08/13 19:40:35 UTC
svn commit: r685618 -
/logging/log4j/trunk/src/main/java/org/apache/log4j/spi/LocationInfo.java
Author: carnold
Date: Wed Aug 13 10:40:34 2008
New Revision: 685618
URL: http://svn.apache.org/viewvc?rev=685618&view=rev
Log:
Bug 45039: Rework to work from bottom down and explicitly format fullinfo
Modified:
logging/log4j/trunk/src/main/java/org/apache/log4j/spi/LocationInfo.java
Modified: logging/log4j/trunk/src/main/java/org/apache/log4j/spi/LocationInfo.java
URL: http://svn.apache.org/viewvc/logging/log4j/trunk/src/main/java/org/apache/log4j/spi/LocationInfo.java?rev=685618&r1=685617&r2=685618&view=diff
==============================================================================
--- logging/log4j/trunk/src/main/java/org/apache/log4j/spi/LocationInfo.java (original)
+++ logging/log4j/trunk/src/main/java/org/apache/log4j/spi/LocationInfo.java Wed Aug 13 10:40:34 2008
@@ -131,34 +131,42 @@
return;
if (getLineNumberMethod != null) {
try {
- boolean hitCaller = false;
Object[] noArgs = null;
Object[] elements = (Object[]) getStackTraceMethod.invoke(t, noArgs);
- for(int i = 0; i < elements.length; i++) {
- String thisClass = String.valueOf(getClassNameMethod.invoke(elements[i], noArgs));
- boolean isCaller = thisClass.equals(fqnOfCallingClass);
- if (hitCaller) {
- if(!isCaller) {
- className = thisClass;
- methodName = (String) getMethodNameMethod.invoke(elements[i], noArgs);
- fileName = (String) getFileNameMethod.invoke(elements[i], noArgs);
+ String prevClass = NA;
+ for(int i = elements.length - 1; i >= 0; i--) {
+ String thisClass = (String) getClassNameMethod.invoke(elements[i], noArgs);
+ if(fqnOfCallingClass.equals(thisClass)) {
+ int caller = i + 1;
+ if (caller < elements.length) {
+ className = prevClass;
+ methodName = (String) getMethodNameMethod.invoke(elements[caller], noArgs);
+ fileName = (String) getFileNameMethod.invoke(elements[caller], noArgs);
if (fileName == null) {
fileName = NA;
}
- int line = ((Integer) getLineNumberMethod.invoke(elements[i], noArgs)).intValue();
+ int line = ((Integer) getLineNumberMethod.invoke(elements[caller], noArgs)).intValue();
if (line < 0) {
lineNumber = NA;
} else {
lineNumber = String.valueOf(line);
}
- fullInfo = elements[i].toString();
- return;
+ StringBuffer buf = new StringBuffer();
+ buf.append(className);
+ buf.append(".");
+ buf.append(methodName);
+ buf.append("(");
+ buf.append(fileName);
+ buf.append(":");
+ buf.append(lineNumber);
+ buf.append(")");
+ this.fullInfo = buf.toString();
}
- } else {
- hitCaller = isCaller;
+ return;
}
+ prevClass = thisClass;
}
-
+ return;
} catch(Exception ex) {
LogLog.debug("LocationInfo failed using JDK 1.4 methods", ex);
}
---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-dev-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-dev-help@logging.apache.org