While you are at it, we can fix it. Can you please check if the changes suggested in the diff below are satisfactory. The additional comments are just to explain the changes and are not meant to be committed.

Index: framework/service/src/org/ofbiz/service/ServiceDispatcher.java
===================================================================
--- framework/service/src/org/ofbiz/service/ServiceDispatcher.java (revision 1452030) +++ framework/service/src/org/ofbiz/service/ServiceDispatcher.java (working copy)
@@ -586,28 +586,18 @@
         } 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() || modelService.debug) && 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()) {
+        // if service instructs debugging, then definitely print it
+ if (modelService.debug || (Debug.verboseOn() && timeToRun > 50) || (Debug.infoOn() && timeToRun > 200)) { // 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]";
             }
+ // we have already checked verboseOn and infoOn, so we are good to go with the log method than doing an additional check
             if (!modelService.hideResultInLog) {
- Debug.logInfo("Sync service [" + localName + "/" + modelService.name + "] finished in [" + timeToRun + "] milliseconds with response [" + resultStr + "]", module); + Debug.log("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.log("Sync service [" + localName + "/" + modelService.name + "] finished in [" + timeToRun + "] milliseconds", module);
             }
         }


On Thu, 04 Apr 2013 17:29:51 +0530, Adrian Crum <[email protected]> wrote:

I agree that bit of code is messy and confusing.

if ((Debug.verboseOn()...
...
   Debug.logTiming(...

Huh? Shouldn't that be

   Debug.logVerbose(...

?

If I have verbose on and timing off, then I will never see the log messages.

I really don't understand all of this complicated decision-making about generating a log message. You don't see anything like it anywhere else.

-Adrian

On 4/4/2013 12:49 PM, Atul Vani wrote:
There is something wrong with the code in the next few lines too.


if ((Debug.verboseOn() || modelService.debug) && timeToRun > 50 && !modelService.hideResultInLog) {// *if I have set debug to true then it should also display for timeToRun<50*
            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 {// *this will never get called bacause of the parent IF condition !modelService.hideResultInLog* Debug.logTiming("Sync service [" + localName + "/" + modelService.name + "] finished in [" + timeToRun + "] milliseconds", module);
            }
        } else if (timeToRun > 200 && Debug.infoOn()) {
// *this code is very similar to the one above (except logTiming and logInfo), can't we remove duplicacy somehow (might wanna use timingOn() method)*
            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);

            }
        }


On Wed, 03 Apr 2013 13:27:25 +0530, <[email protected]> wrote:

Author: adrianc
Date: Wed Apr  3 07:57:24 2013
New Revision: 1463863

URL: http://svn.apache.org/r1463863
Log:
Log message cleanup in ServiceDispatcher.java. Removed confusing text about services taking too long.

Modified:
ofbiz/trunk/framework/service/src/org/ofbiz/service/ServiceDispatcher.java

Modified: ofbiz/trunk/framework/service/src/org/ofbiz/service/ServiceDispatcher.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/service/src/org/ofbiz/service/ServiceDispatcher.java?rev=1463863&r1=1463862&r2=1463863&view=diff ============================================================================== --- ofbiz/trunk/framework/service/src/org/ofbiz/service/ServiceDispatcher.java (original) +++ ofbiz/trunk/framework/service/src/org/ofbiz/service/ServiceDispatcher.java Wed Apr 3 07:57:24 2013
@@ -571,10 +571,8 @@ public class ServiceDispatcher {
         rs.setEndStamp();
        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.timingOn()) {
+ Debug.logTiming("Sync service [" + localName + "/" + modelService.name + "] finished in [" + timeToRun + "] milliseconds", module);
         }
if ((Debug.verboseOn() || modelService.debug) && timeToRun > 50 && !modelService.hideResultInLog) { // Sanity check - some service results can be multiple MB in size. Limit message size to 10K.







--
Using Opera's revolutionary email client: http://www.opera.com/mail/

Reply via email to