volosied commented on code in PR #520:
URL: https://github.com/apache/myfaces/pull/520#discussion_r1106306711


##########
impl/src/main/resources/META-INF/WebConfigParamsLogger.vm:
##########
@@ -34,88 +34,88 @@ public class WebConfigParamsLogger
 {
     private static final Logger log = 
Logger.getLogger(WebConfigParamsLogger.class.getName());
 
+    private static Boolean LOG_WEB_CONTEXT_PARAM = false;
+
     public static void logWebContextParams(FacesContext facesContext)
     {
         MyfacesConfig myfacesConfig = 
MyfacesConfig.getCurrentInstance(facesContext.getExternalContext());
 
-        if (!myfacesConfig.isLogWebContextParams())
-        {
-            //No log if is disabled or is in auto mode and project stage is 
UnitTest or SystemTest
-            return;
-        }
+        LOG_WEB_CONTEXT_PARAM = myfacesConfig.isLogWebContextParams();
 
-
-        if(myfacesConfig.isRiImplAvailable() && 
myfacesConfig.isMyfacesImplAvailable())
+        if(myfacesConfig.isRiImplAvailable() && 
myfacesConfig.isMyfacesImplAvailable() && log.isLoggable(Level.SEVERE))
         {
             log.severe("Both MyFaces and the RI are on your classpath. Please 
make sure to use only one of the two JSF-implementations.");
         }
 
-
 ## ----------------------------- PROPERTY MACROS -----------------------------
 ##
 ## -------------------------------
 ## writePropertyCheck
 ## -------------------------------
 ##
 #macro (writePropertyCheck $webConfigParam)
-            paramValue = 
facesContext.getExternalContext().getInitParameter("$webConfigParam.name");
-            if (paramValue == null)
-            {
-                log.info("No context init parameter '$webConfigParam.name' 
found#if($webConfigParam.defaultValue), using default value 
'$webConfigParam.defaultValue'#end.");
-            }
+        paramValue = 
facesContext.getExternalContext().getInitParameter("$webConfigParam.name");
+        if (paramValue == null)
+        {
+            logMessageToAppropriateLevel("No context init parameter 
'$webConfigParam.name' found#if($webConfigParam.defaultValue), using default 
value '$webConfigParam.defaultValue'#end.");
+        }
 #if (!$webConfigParam.isDeprecated())
 #if ($webConfigParam.expectedValues)
-            else
+        else
+        {
+            boolean found = false;
+            String[] expectedValues = 
StringUtils.trim(StringUtils.splitShortString("$webConfigParam.expectedValues",','));
+            for (int i = 0; i < expectedValues.length; i++)
             {
-                boolean found = false;
-                String[] expectedValues = 
StringUtils.trim(StringUtils.splitShortString("$webConfigParam.expectedValues",','));
-                for (int i = 0; i < expectedValues.length; i++)
-                {
 #if ($webConfigParam.isIgnoreUpperLowerCase())
-                    if (paramValue.equalsIgnoreCase(expectedValues[i]))
+                if (paramValue.equalsIgnoreCase(expectedValues[i]))
 #else
-                    if (paramValue.equals(expectedValues[i]))
+                if (paramValue.equals(expectedValues[i]))
 #end
-                    {
-                        found = true;
-                        break;
-                    }
-                }
-                if (!found)
                 {
-                    if (log.isLoggable(Level.WARNING))
-                    {
-                        log.warning("Wrong value in context init parameter 
'$webConfigParam.name' (='" + paramValue + "'), using default value 
#if($webConfigParam.defaultValue)'$webConfigParam.defaultValue'#else'null'#end");
-                    }
+                    found = true;
+                    break;
                 }
             }
-#elseif ($webConfigParam.classType)
-            else
+            if (!found)
             {
-                try
+                if (log.isLoggable(Level.WARNING))
                 {
-                    ${webConfigParam.classType}.valueOf(paramValue);
+                    log.warning("Wrong value in context init parameter 
'$webConfigParam.name' (='" + paramValue + "'), using default value 
#if($webConfigParam.defaultValue)'$webConfigParam.defaultValue'#else'null'#end");
                 }
-                catch(Exception e)
+            }
+            else
+            {
+                logMessageToAppropriateLevel("Init context parameter found 
'$webConfigParam.name' set to '" + paramValue + "'");
+            }
+        }
+#elseif ($webConfigParam.classType)
+        else
+        {
+            try
+            {
+                ${webConfigParam.classType}.valueOf(paramValue);
+            }
+            catch(Exception e)
+            {
+                if (log.isLoggable(Level.WARNING))
                 {
-                    if (log.isLoggable(Level.WARNING))
-                    {
-                        log.warning("Wrong value in context init parameter 
'$webConfigParam.name' (='" + paramValue + "'), using default value 
#if($webConfigParam.defaultValue)'$webConfigParam.defaultValue'#else'null'#end");
-                    }
+                    log.warning("Wrong value in context init parameter 
'$webConfigParam.name' (='" + paramValue + "'), using default value 
#if($webConfigParam.defaultValue)'$webConfigParam.defaultValue'#else'null'#end");

Review Comment:
   Majority of the "changes" are just me indenting this to the left once since 
I removed an if statement this code was nested in. 



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscr...@myfaces.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to