Add log message when a request starts evaluating, and make commit log message look nicer and easier to parse.

This commit is contained in:
hns 2008-10-16 15:06:44 +00:00
parent ee391ae6db
commit f1dd9c6f37
2 changed files with 20 additions and 11 deletions

View file

@ -159,6 +159,9 @@ public final class RequestEvaluator implements Runnable {
// request path object // request path object
RequestPath requestPath = new RequestPath(app); RequestPath requestPath = new RequestPath(app);
String txname = req.getMethod().toLowerCase() + ":" + req.getPath();
app.logEvent(txname + " starting");
int tries = 0; int tries = 0;
boolean done = false; boolean done = false;
Throwable error = null; Throwable error = null;
@ -202,14 +205,14 @@ public final class RequestEvaluator implements Runnable {
throw new IllegalStateException("No function name in non-internal request "); throw new IllegalStateException("No function name in non-internal request ");
} }
// Transaction name is used for logging etc. // Update transaction name in case we're processing an error
StringBuffer txname = new StringBuffer(app.getName()); if (error != null) {
txname.append(":").append(req.getMethod().toLowerCase()).append(":"); txname = txname + ":error";
txname.append((error == null) ? req.getPath() : "error"); }
// begin transaction // begin transaction
transactor = Transactor.getInstance(app.nmgr); transactor = Transactor.getInstance(app.nmgr);
transactor.begin(txname.toString()); transactor.begin(txname);
Object root = app.getDataRoot(); Object root = app.getDataRoot();
initGlobals(root, requestPath); initGlobals(root, requestPath);
@ -604,7 +607,7 @@ public final class RequestEvaluator implements Runnable {
error = x; error = x;
Transactor tx = Transactor.getInstance(); Transactor tx = Transactor.getInstance();
String txname = tx == null ? "no-txn" : tx.getTransactionName(); txname = tx == null ? "no-txn" : tx.getTransactionName();
app.logError(txname + ": " + error, x); app.logError(txname + ": " + error, x);
if (req.isXmlRpc()) { if (req.isXmlRpc()) {
@ -624,8 +627,9 @@ public final class RequestEvaluator implements Runnable {
} finally { } finally {
app.setCurrentRequestEvaluator(null); app.setCurrentRequestEvaluator(null);
// exit execution context // exit execution context
if (scriptingEngine != null) if (scriptingEngine != null) {
scriptingEngine.exitContext(); scriptingEngine.exitContext();
}
} }
} }

View file

@ -419,10 +419,15 @@ public class Transactor {
txn = null; txn = null;
} }
nmgr.app.logAccess(tname + " " + inserted + StringBuffer msg = new StringBuffer(tname).append(" done in ")
" inserted, " + updated + .append(now - tstart).append(" millis");
" updated, " + deleted + " deleted in " + if(inserted + updated + deleted > 0) {
(now - tstart) + " millis"); msg.append(" [+")
.append(inserted).append(", ~")
.append(updated).append(", -")
.append(deleted).append("]");
}
nmgr.app.logAccess(msg.toString());
// unset transaction name // unset transaction name
tname = null; tname = null;