From d7a92cea278063249beeede9cf132e5539a2ec79 Mon Sep 17 00:00:00 2001 From: Jacopo Cappellato Date: Fri, 1 Jun 2012 08:12:46 +0000 Subject: [PATCH] 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 --- .../org/ofbiz/service/ServiceDispatcher.java | 24 +++++-------------- 1 file changed, 6 insertions(+), 18 deletions(-) diff --git a/framework/service/src/org/ofbiz/service/ServiceDispatcher.java b/framework/service/src/org/ofbiz/service/ServiceDispatcher.java index 2cdff58edc..a9fd92a85b 100644 --- a/framework/service/src/org/ofbiz/service/ServiceDispatcher.java +++ b/framework/service/src/org/ofbiz/service/ServiceDispatcher.java @@ -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; }