[ 
https://issues.apache.org/jira/browse/CAMEL-3759?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13006186#comment-13006186
 ] 

Christian Müller commented on CAMEL-3759:
-----------------------------------------

slfj4 also has the following interface:
{code}
public void info(String format, Object[] argArray);
{code}
With this it's possible to get rid of the isXXXEnabled() statements.

I also found some log statements like this one:
{code}
if (log.isInfoEnabled()) {
    log.info("Loaded " + typeMappings.size() + " type converters in " + 
TimeUtils.printDuration(watch.stop()));
}
{code}

which we could refactor to 
{code}
log.info("Loaded {} type converters in {}"), typeMappings.size(), 
TimeUtils.printDuration(watch.stop());
{code}

but I assume "TimeUtils.printDuration(watch.stop())" is an expensive operation 
which should only be executed if we want log this statement. Therefore I would 
refactor some similar parts of the code to
{code}
if (log.isInfoEnabled()) {
    log.info("Loaded {} type converters in {}"), typeMappings.size(), 
TimeUtils.printDuration(watch.stop());
}
{code}

> After switching to slf4j, we can get rid of the 'isTraceEnabled', 
> 'isDebugEnabled' and 'isInfoEnabled' statements
> -----------------------------------------------------------------------------------------------------------------
>
>                 Key: CAMEL-3759
>                 URL: https://issues.apache.org/jira/browse/CAMEL-3759
>             Project: Camel
>          Issue Type: Improvement
>    Affects Versions: 2.6.0
>            Reporter: Christian Müller
>            Assignee: Christian Müller
>             Fix For: 2.8.0, 3.0.0
>
>
> we can get rid of the 'isTraceEnabled', 'isDebugEnabled' and 'isInfoEnabled' 
> statements with slf4j and use
> {code}
> logger.debug("Temperature set to {}. Old temperature was {}.", t, oldT);
> {code}
> instead
> christian-muellers-macbook-pro:camel cmueller$ egrep -r 
> 'isTraceEnabled|isDebugEnabled|isInfoEnabled]' . | wc -l
>     1485

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

Reply via email to