Improved error messages that notify when a service's time to run was over some given threasholds.

Refactored code (simplified and removed duplicated block) that logs, in these cases, the output of the service; now the service output is only printed in verbose mode (of course if the other conditions hold true).



git-svn-id: https://svn.apache.org/repos/asf/ofbiz/trunk@1345005 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Jacopo Cappellato
2012-06-01 08:12:46 +00:00
parent df927cd6dd
commit d7a92cea27
@@ -587,30 +587,18 @@ public class ServiceDispatcher {
long timeToRun = System.currentTimeMillis() - serviceStartTime;
if (Debug.timingOn() && timeToRun > 50) {
Debug.logTiming("Slow sync service execution detected: service [" + localName + "/" + modelService.name + "] finished in [" + timeToRun + "] milliseconds", module);
} else if (Debug.infoOn() && timeToRun > 200) {
Debug.logInfo("Very slow sync service execution detected: service [" + localName + "/" + modelService.name + "] finished in [" + timeToRun + "] milliseconds", module);
}
if (Debug.verboseOn() && timeToRun > 50 && !modelService.hideResultInLog) {
// Sanity check - some service results can be multiple MB in size. Limit message size to 10K.
String resultStr = result.toString();
if (resultStr.length() > 10240) {
resultStr = resultStr.substring(0, 10226) + "...[truncated]";
}
if (!modelService.hideResultInLog) {
Debug.logTiming("Sync service [" + localName + "/" + modelService.name + "] finished in [" + timeToRun + "] milliseconds with response [" + resultStr + "]", module);
} else {
Debug.logTiming("Sync service [" + localName + "/" + modelService.name + "] finished in [" + timeToRun + "] milliseconds", module);
}
} else if (timeToRun > 200 && Debug.infoOn()) {
// Sanity check - some service results can be multiple MB in size. Limit message size to 10K.
String resultStr = result.toString();
if (resultStr.length() > 10240) {
resultStr = resultStr.substring(0, 10226) + "...[truncated]";
}
if (!modelService.hideResultInLog) {
Debug.logInfo("Sync service [" + localName + "/" + modelService.name + "] finished in [" + timeToRun + "] milliseconds with response [" + resultStr + "]", module);
} else {
Debug.logInfo("Sync service [" + localName + "/" + modelService.name + "] finished in [" + timeToRun + "] milliseconds", module);
}
Debug.logVerbose("Sync service [" + localName + "/" + modelService.name + "] finished with response [" + resultStr + "]", module);
}
return result;
}