Yes, I agree that the code is much more bloated with this but I found it does help a lot.  It's not the performance I worry about here but memory consumption.  I run into very serious memory complains (caused by the Logger) even with all logging levels disabled. It happens especially when sending such APIs as getImage(), getDocuments() which deal with huge strings. Since wrapping the calls with this check it all looks so much better. I would feel very uncomfortable removing them after seeing  such memory issues.  And the hardest part of implementing the checks is already done anyway :)

On Feb 18, 2014, at 12:24 AM, thobach <notifications@github.com> wrote:

> In src/com/mambu/apisdk/util/RequestExecutorImpl.java:
> 
> > @@ -104,12 +105,17 @@ public String executeRequest(String urlString, ParamsMap params, Method method,
> >  			params.addParam(APPLICATION_KEY, applicationKey);
> >  
> >  			// Log the App key (the first 3 and last 3 chars only)
> > -			final int keyLength = applicationKey.length();
> > -			final int printLength = 3;
> > -			// Mambu App Keys are very long but just to prevent any errors need to ensure there is enough to print
> > -			if (keyLength >= printLength)
> > -				LOGGER.info("Added Application key=" + applicationKey.substring(0, printLength) + "..."
> > -						+ applicationKey.substring(keyLength - printLength, keyLength));
> > +			// Wrap LOGGER calls with a check for the Logger Level:
> > +			// See http://www.sw-engineering-candies.com/blog-1/thewronguseofloggingcanbeaperformancekillerinjava
> > +			if (LOGGER.isLoggable(Level.INFO)) {
> IMHO this optimization is not necessary as the code gets more bloated. The referenced blog post also uses Math.random() inside the log message which takes some time to generate as well. The effect should be in the micro-seconds here so it's probably not worth it considering the extra code.
> 
> —
> Reply to this email directly or view it on GitHub.
>