Commits

David Carr committed 665c59f

logging: add more debug logging, make better use of slf4j features

  • Participants
  • Parent commits 0c03a19

Comments (0)

Files changed (3)

PageResourcesGrailsPlugin.groovy

         pageResourcesModuleRequester(PageResourcesModuleRequester)
         pageResourcesInterceptor(PageResourcesInterceptor)
         if (manager?.hasGrailsPlugin('webflow')) {
+            log.debug('Registering flow execution listener based on detection of webflow plugin')
             pageResourcesFlowExecutionListener(PageResourcesFlowExecutionListener)
             def flowListeners = [ref('pageResourcesFlowExecutionListener')]
             def oldExecutionListenerLoaderBeanDef = delegate.getBeanDefinition('executionListenerLoader')
             if (oldExecutionListenerLoaderBeanDef) {
+                log.debug('Adding flow execution listener to existing execution listeners')
                 oldExecutionListenerLoaderBeanDef.constructorArgumentValues.getGenericArgumentValues().each {
                     flowListeners.add(it.value)
                 }

grails-app/conf/ZZZPageResources.groovy

 import org.grails.plugin.resource.ResourceProcessor
 import org.slf4j.LoggerFactory
 
-def log = LoggerFactory.getLogger('org.grails.plugin.resource.page.PageResources')
+def log = LoggerFactory.getLogger('org.grails.plugin.resources.page.PageResources')
 def application = ApplicationHolder.application
 def config = application.config
 ResourceProcessor grailsResourceProcessor = application.mainContext.getBean('grailsResourceProcessor')
     // This file should be named such that it comes alphabetically after any *Resources files that contain explicit
     // page module definitions.  Otherwise, it will overrride the other definition.
 
+    def defaultBundleVal = config.flatten().get('grails.plugins.pageResources.defaultBundle')
+    log.debug('defaultBundle configured as: {}', defaultBundleVal)
     def dependModuleName = 'defaultPageDependencies'
     def dependModule = delegate._modules.find { it.name == dependModuleName }
     def pageResources = mainContext.getResources('/pages/**')
         String moduleName = modulePath[1..-2].replaceAll(/[\/\\]/, '_')
         def module = delegate._modules.find { it.name == moduleName }
         if (module) {
-            if (log.isDebugEnabled()) {
-                log.debug("Page module ${moduleName} already defined; using pre-existing definition")
-            }
+            log.debug("Page module {} already defined; using pre-existing definition", moduleName)
         } else {
             def fileResources = pageResources.findAll{ pageResource ->
                 !pageResource.filename.empty && pageResource.path.startsWith(modulePath) && pageResource.path.indexOf('/', modulePath.length()) == -1
             }.findAll{ pageResource ->
                 boolean supported = grailsResourceProcessor.getDefaultSettingsForURI(pageResource.path)
                 if (!supported) {
-                    log.info("Ignoring file of unsupported type: ${pageResource.path}")
+                    log.info("Ignoring file of unsupported type: {}", pageResource.path)
                 }
                 return supported
             }.sort()
             if (!fileResources.isEmpty()) {
-                if (log.isInfoEnabled()) {
-                    log.info("Defining page module: ${moduleName}")
-                }
+                log.info("Defining page module: {}", moduleName)
                 delegate.invokeMethod(moduleName) {
                     if (dependModule) {
                         dependsOn(dependModuleName)
                     }
-                    def defaultBundleVal = config.flatten().get('grails.plugins.pageResources.defaultBundle')
                     if (defaultBundleVal instanceof CharSequence) {
                         defaultBundle(defaultBundleVal)
                     } else if (!defaultBundleVal) {

src/groovy/org/grails/plugin/resources/page/PageResourcesModuleRequester.groovy

         if (viewName) {
             String moduleName = 'pages' + viewName.replaceAll('/', '_')
             if (resourceProcessor.getModule(moduleName)) {
-                if (log.isDebugEnabled()) {
-                    log.debug("Automatically requiring page module ${moduleName} for view ${viewName}")
-                }
+                log.debug('Automatically requiring page module {} for view {}', moduleName, viewName)
                 resourceTagLib.require(module: moduleName)
+            } else {
+                log.debug('No page module {} defined for view {}', moduleName, viewName)
             }
         }
     }