VIVO-452 refine the LoggingRDFService.
This commit is contained in:
parent
15e0fc0e39
commit
d3a90915a6
1 changed files with 18 additions and 5 deletions
|
@ -35,8 +35,8 @@ import edu.cornell.mannlib.vitro.webapp.config.ConfigurationProperties;
|
||||||
* requested.
|
* requested.
|
||||||
*
|
*
|
||||||
* The stack trace is abbreviated. It will reach into this class, and will not
|
* The stack trace is abbreviated. It will reach into this class, and will not
|
||||||
* extend past the first reference to the ApplicationFilterChain. Perhaps it
|
* extend past the first reference to the ApplicationFilterChain. It also omits
|
||||||
* should be abbreviated further?
|
* any Jena classes. Perhaps it should be abbreviated further?
|
||||||
*/
|
*/
|
||||||
public class RDFServiceLogger implements AutoCloseable {
|
public class RDFServiceLogger implements AutoCloseable {
|
||||||
private static final Log log = LogFactory.getLog(RDFServiceLogger.class);
|
private static final Log log = LogFactory.getLog(RDFServiceLogger.class);
|
||||||
|
@ -96,6 +96,7 @@ public class RDFServiceLogger implements AutoCloseable {
|
||||||
|
|
||||||
trimStackTraceAtBeginning(list);
|
trimStackTraceAtBeginning(list);
|
||||||
trimStackTraceAtEnd(list);
|
trimStackTraceAtEnd(list);
|
||||||
|
removeJenaClassesFromStackTrace(list);
|
||||||
|
|
||||||
if (list.isEmpty()) {
|
if (list.isEmpty()) {
|
||||||
this.methodName = "UNKNOWN";
|
this.methodName = "UNKNOWN";
|
||||||
|
@ -104,6 +105,8 @@ public class RDFServiceLogger implements AutoCloseable {
|
||||||
}
|
}
|
||||||
|
|
||||||
this.trace = list;
|
this.trace = list;
|
||||||
|
log.debug("Stack array: " + Arrays.toString(stack));
|
||||||
|
log.debug("Stack trace: " + this.trace);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void trimStackTraceAtBeginning(List<StackTraceElement> list) {
|
private void trimStackTraceAtBeginning(List<StackTraceElement> list) {
|
||||||
|
@ -131,12 +134,22 @@ public class RDFServiceLogger implements AutoCloseable {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void removeJenaClassesFromStackTrace(List<StackTraceElement> list) {
|
||||||
|
ListIterator<StackTraceElement> iter = list.listIterator();
|
||||||
|
while (iter.hasNext()) {
|
||||||
|
StackTraceElement ste = iter.next();
|
||||||
|
if (ste.getClassName().startsWith("com.hp.hpl.jena.")) {
|
||||||
|
iter.remove();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private boolean passesRestrictions() {
|
private boolean passesRestrictions() {
|
||||||
if (restriction == null) {
|
if (restriction == null) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
for (StackTraceElement ste : trace) {
|
for (StackTraceElement ste : trace) {
|
||||||
if (restriction.matcher(ste.getClassName()).matches()) {
|
if (restriction.matcher(ste.getClassName()).find()) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -163,8 +176,8 @@ public class RDFServiceLogger implements AutoCloseable {
|
||||||
|
|
||||||
if (traceRequested) {
|
if (traceRequested) {
|
||||||
for (StackTraceElement ste : trace) {
|
for (StackTraceElement ste : trace) {
|
||||||
sb.append(String.format("\n %d %s", ste.getLineNumber(),
|
sb.append(String.format("\n line %d4, %s",
|
||||||
ste.getClassName()));
|
ste.getLineNumber(), ste.getClassName()));
|
||||||
}
|
}
|
||||||
sb.append("\n ...");
|
sb.append("\n ...");
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue