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

ASF GitHub Bot commented on MNG-7866:
-------------------------------------

sebastien-doyon opened a new pull request, #1220:
URL: https://github.com/apache/maven/pull/1220

   Use message formats with placeholders to avoid premature formatting and 
avoid the unnecessary garbage when then log level is disabled :
   
   org.apache.maven.project.artifact.MavenMetadataSource
   org.apache.maven.toolchain.DefaultToolchainsBuilder
   org.apache.maven.DefaultMaven
   org.apache.maven.classrealm.DefaultClassRealmManager
   org.apache.maven.internal.aether.LoggingRepositoryListener
   org.apache.maven.lifecycle.internal.DefaultLifecyclePluginAnalyzer
   org.apache.maven.lifecycle.internal.LifecycleDependencyResolver
   
org.apache.maven.lifecycle.internal.builder.multithreaded.MultiThreadedBuilder
   org.apache.maven.plugin.internal.DefaultMavenPluginManager
   org.apache.maven.plugin.internal.DefaultPluginDependenciesResolver
   org.apache.maven.plugin.prefix.internal.DefaultPluginPrefixResolver
   org.apache.maven.plugin.version.internal.DefaultPluginVersionResolver
   org.apache.maven.project.collector.MultiModuleCollectionStrategy
   org.apache.maven.toolchain.DefaultToolchain
   
   Guarding some logging statements with conditionals on isXXXXEnabled() to 
avoid unnecessary garbage when then log level is disabled. Useful when some 
formatting must be done outside the logger call :
   
   org.apache.maven.classrealm.DefaultClassRealmManager
   org.apache.maven.internal.impl.DefaultLog
   org.apache.maven.lifecycle.DefaultLifecycles
   org.apache.maven.plugin.internal.DefaultMavenPluginManager
   org.apache.maven.plugin.internal.MojoLogWrapper
   
   Remove some unneeded conditional guarding to avoid testing twice if the log 
level is enabled :
   
   org.apache.maven.classrealm.DefaultClassRealmManager
   org.apache.maven.lifecycle.DefaultLifecycles
   org.apache.maven.plugin.prefix.internal.DefaultPluginPrefixResolver
   org.apache.maven.plugin.version.internal.DefaultPluginVersionResolver
   
   New test class :
   
   org.apache.maven.classrealm.DefaultClassRealmManagerTest
   
   Test class modified to reflect the new logger API usage :
   
   org.apache.maven.toolchain.DefaultToolchainTest




> Improvements to the logging API usage (technical debt)
> ------------------------------------------------------
>
>                 Key: MNG-7866
>                 URL: https://issues.apache.org/jira/browse/MNG-7866
>             Project: Maven
>          Issue Type: Improvement
>          Components: Core
>    Affects Versions: 4.0.0-alpha-2
>            Reporter: sebastien
>            Priority: Minor
>
> Since maven 4 is now using the Slf4J logger API, some logging code can be 
> improved.
> Typical improvements are:
>  * Use message formats with placeholders to avoid premature formatting and 
> avoid the unnecessary garbage when then log level is disabled. Example :
>  
> {code:java}
>             logger.debug("Toolchains configuration was not found at " + 
> userToolchainsFile);
> {code}
> can be replaced with :
> {code:java}
>             logger.debug("Toolchains configuration was not found at {}", 
> userToolchainsFile);{code}
>  * Guarding some logging statements with conditionals on isXXXXEnabled() to 
> avoid unnecessary garbage when then log level is disabled. Useful when some 
> formatting must be done outside the logger call. Example :
>  
> {code:java}
>                 } else {
>                     Lifecycle original = phaseToLifecycleMap.get(phase);
>                     logger.warn("Duplicated lifecycle phase " + phase + ". 
> Defined in " + original.getId()
>                             + " but also in " + lifecycle.getId());
>                 }
> {code}
> can be replaced with the following code to avoid the cost of the map lookup :
>  
> {code:java}
>                 } else if (logger.isWarnEnabled()) {
>                     Lifecycle original = phaseToLifecycleMap.get(phase);
>                     logger.warn(
>                             "Duplicated lifecycle phase {}. Defined in {} but 
> also in {}",
>                             phase,
>                             original.getId(),
>                             lifecycle.getId());
>                 }
> {code}
>  * Remove some unneeded conditional guarding to avoid testing twice if the 
> log level is enabled, like for example :
>  
> {code:java}
>             if (logger.isDebugEnabled()) {
>                 logger.debug("Lifecycle " + lifecycle);
>             }
> {code}
> can be replaced with :
> {code:java}
>             logger.debug("Lifecycle {}", lifecycle);{code}



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to