Minor profiler and logging tweaks
This commit is contained in:
parent
bd1e9dcc25
commit
5d130c9ecb
4 changed files with 20 additions and 7 deletions
|
@ -621,6 +621,10 @@ public class RequestTrans implements Serializable {
|
|||
}
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
return method + ":" + path;
|
||||
}
|
||||
|
||||
class ParameterMap extends SystemMap {
|
||||
|
||||
public ParameterMap() {
|
||||
|
|
|
@ -160,7 +160,7 @@ public final class RequestEvaluator implements Runnable {
|
|||
// request path object
|
||||
RequestPath requestPath = new RequestPath(app);
|
||||
|
||||
String txname = req.getMethod().toLowerCase() + ":" + req.getPath();
|
||||
String txname = req.getMethod() + ":" + req.getPath();
|
||||
Log eventLog = app.getEventLog();
|
||||
if (eventLog.isDebugEnabled()) {
|
||||
eventLog.debug(txname + " starting");
|
||||
|
|
|
@ -220,7 +220,7 @@ public class RhinoEngine implements ScriptingEngine {
|
|||
if (res != null) {
|
||||
getResponse().debug("<pre>" + result + "</pre>");
|
||||
}
|
||||
app.logEvent(result);
|
||||
app.logEvent("Profiler data for " + getRequest() + ":\n" + result);
|
||||
} catch (Exception x) {
|
||||
app.logError("Error in profiler: " + x, x);
|
||||
}
|
||||
|
|
|
@ -49,7 +49,8 @@ public class Profiler implements Debugger {
|
|||
if (script.isFunction()) {
|
||||
StringBuffer b = new StringBuffer(script.getSourceName()).append(" #");
|
||||
b.append(script.getLineNumbers()[0]);
|
||||
if (script.getFunctionName() != null) {
|
||||
String funcName = script.getFunctionName();
|
||||
if (funcName != null && funcName.length() > 0) {
|
||||
b.append(": ").append(script.getFunctionName());
|
||||
}
|
||||
return b.toString();
|
||||
|
@ -66,13 +67,21 @@ public class Profiler implements Debugger {
|
|||
}
|
||||
});
|
||||
int length = Math.min(100, f.length);
|
||||
int prefixLength = Integer.MAX_VALUE;
|
||||
for (int i = 0; i < length - 1; i++) {
|
||||
prefixLength = Math.min(prefixLength,
|
||||
int prefixLength = length < 2 ? 0 : Integer.MAX_VALUE;
|
||||
int maxLength = 0;
|
||||
for (int i = 0; i < length; i++) {
|
||||
maxLength = Math.max(maxLength, f[i].name.length());
|
||||
if (i < length - 1) {
|
||||
prefixLength = Math.min(prefixLength,
|
||||
StringUtils.getCommonPrefix(f[i].name, f[i+1].name).length());
|
||||
}
|
||||
}
|
||||
maxLength = maxLength + 30 - prefixLength;
|
||||
StringBuffer buffer = new StringBuffer(" total average calls path\n");
|
||||
buffer.append("==================================================================\n");
|
||||
for (int i = 0; i < maxLength; i++) {
|
||||
buffer.append('-');
|
||||
}
|
||||
buffer.append('\n');
|
||||
for (int i = 0; i < length; i++) {
|
||||
buffer.append(f[i].renderLine(prefixLength));
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue