You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@wink.apache.org by "Bryant Luk (JIRA)" <ji...@apache.org> on 2009/10/08 19:16:31 UTC

[jira] Commented: (WINK-213) scrub code for debug log behavior

    [ https://issues.apache.org/jira/browse/WINK-213?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12763574#action_12763574 ] 

Bryant Luk commented on WINK-213:
---------------------------------

Just some background:

http://slf4j.org/faq.html#logging_performance

It doesn't seem to hurt performance too much if we do not have an if clause with isDebugEnabled().  I only added the "if" statement when I needed to construct something else or make additional method calls.

So whenever additional calls are made or checks need to be done:

{code}
if(logger.isDebugEnabled()) {
  List<Annotation> anns = (annArray == null) ? null : Arrays.asList(annArray);
  logger.debug("annotations were {} ", anns);
}
{code}

Otherwise if no new objects are being created and/or no new method calls need to be made:

{code}
MediaTypeMap map = ...;
logger.debug("hello world {}", map);
{code}

Technically I think the autoboxing statements should have an if(logger.isDebugEnabled()) but I wasn't too careful there:

{code}
int i = 0;
if(logger.isDebugEnabled()) {
logger.debug("autoboxed int {}", i);
}
{code}


> scrub code for debug log behavior
> ---------------------------------
>
>                 Key: WINK-213
>                 URL: https://issues.apache.org/jira/browse/WINK-213
>             Project: Wink
>          Issue Type: Improvement
>            Reporter: Mike Rheinheimer
>            Priority: Minor
>
> I've noticed, as I go through code, that some spots have the conditional surrounding the call to logger.debug, like so:
> {code}
>         if (logger.isDebugEnabled()) {
>             logger.debug("debug message");
>         }
> {code}
> Other places in code do not have the conditional.
> So, which is it?  Do we need the conditional or not?  I would assume we do need it because we don't know what the concrete implementation of Logger is in a given runtime container.
> If we do need it, is it worth putting a static boolean in a util class that is queried instead of calling isDebugEnabled every time?  This would give a very slight performance improvement as it would prevent a context switch into the isDebugEnabled method.
> I can work on cleaning all this up.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.