Martin Peřina has uploaded a new change for review.

Change subject: frontend: Replace log4j with slf4j
......................................................................

frontend: Replace log4j with slf4j

Replaces log4j with slf4j.

Change-Id: Iea13c66ca38380e0e6017921d135051e0342f565
Bug-Url: https://bugzilla.redhat.com/1109871
Signed-off-by: Martin Perina <[email protected]>
---
M 
frontend/webadmin/modules/frontend/src/main/java/org/ovirt/engine/ui/frontend/server/gwt/GenericApiGWTServiceImpl.java
M 
frontend/webadmin/modules/frontend/src/main/java/org/ovirt/engine/ui/frontend/server/gwt/XsrfTokenGeneratorHttpSessionListener.java
M 
frontend/webadmin/modules/frontend/src/main/java/org/ovirt/engine/ui/frontend/server/gwt/plugin/PluginDataManager.java
M 
frontend/webadmin/modules/frontend/src/main/java/org/ovirt/engine/ui/frontend/server/gwt/plugin/PluginResourceServlet.java
4 files changed, 35 insertions(+), 40 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/82/34182/1

diff --git 
a/frontend/webadmin/modules/frontend/src/main/java/org/ovirt/engine/ui/frontend/server/gwt/GenericApiGWTServiceImpl.java
 
b/frontend/webadmin/modules/frontend/src/main/java/org/ovirt/engine/ui/frontend/server/gwt/GenericApiGWTServiceImpl.java
index ca76d12..8e17004 100644
--- 
a/frontend/webadmin/modules/frontend/src/main/java/org/ovirt/engine/ui/frontend/server/gwt/GenericApiGWTServiceImpl.java
+++ 
b/frontend/webadmin/modules/frontend/src/main/java/org/ovirt/engine/ui/frontend/server/gwt/GenericApiGWTServiceImpl.java
@@ -7,7 +7,6 @@
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpSession;
 
-import org.apache.log4j.Logger;
 import org.ovirt.engine.core.common.action.LoginUserParameters;
 import org.ovirt.engine.core.common.action.LogoutUserParameters;
 import org.ovirt.engine.core.common.action.VdcActionParametersBase;
@@ -23,6 +22,8 @@
 import org.ovirt.engine.ui.frontend.gwtservices.GenericApiGWTService;
 
 import com.google.gwt.user.client.rpc.SerializationException;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 public class GenericApiGWTServiceImpl extends XsrfProtectedRpcServlet 
implements GenericApiGWTService {
 
@@ -31,7 +32,7 @@
     static Random r = new Random();
     boolean noBackend = false;
 
-    private static final Logger log = 
Logger.getLogger(GenericApiGWTServiceImpl.class);
+    private static final Logger log = 
LoggerFactory.getLogger(GenericApiGWTServiceImpl.class);
 
     private static final String UI_PREFIX = "UI_"; //$NON-NLS-1$
 
@@ -59,7 +60,7 @@
     @Override
     public VdcQueryReturnValue runPublicQuery(VdcQueryType queryType,
             VdcQueryParametersBase params) {
-        log.debug("Server: runPublicQuery invoked! " + queryType); 
//$NON-NLS-1$
+        log.debug("Server: runPublicQuery invoked! '{}'", queryType); 
//$NON-NLS-1$
         debugQuery(queryType, params);
         return getBackend().runPublicQuery(queryType, params);
     }
@@ -69,7 +70,7 @@
             ArrayList<VdcQueryType> queryTypeList,
             ArrayList<VdcQueryParametersBase> queryParamsList) {
         int size = queryTypeList == null ? 0 : queryTypeList.size();
-        log.debug("Server: RunMultipleQuery invoked! [amount of queries: " + 
size + "]"); //$NON-NLS-1$ //$NON-NLS-2$
+        log.debug("Server: RunMultipleQuery invoked! [amount of queries: {}]", 
size); //$NON-NLS-1$
         ArrayList<VdcQueryReturnValue> ret = new 
ArrayList<VdcQueryReturnValue>();
 
         if (queryTypeList == null || queryParamsList == null) {
@@ -89,10 +90,10 @@
         }
 
         for (VdcQueryReturnValue vqrv : ret) {
-            log.debug("VdcQueryReturnValue: " + vqrv); //$NON-NLS-1$
+            log.debug("VdcQueryReturnValue '{}'", vqrv); //$NON-NLS-1$
         }
 
-        log.debug("Server: RunMultipleQuery result [amount of queries: " + 
ret.size() + "]"); //$NON-NLS-1$ //$NON-NLS-2$
+        log.debug("Server: RunMultipleQuery result [amount of queries: {}]", 
ret.size()); //$NON-NLS-1$
 
         return ret;
     }
@@ -106,7 +107,7 @@
     @Override
     public ArrayList<VdcReturnValueBase> runMultipleActions(VdcActionType 
actionType,
             ArrayList<VdcActionParametersBase> multipleParams, boolean 
isRunOnlyIfAllCanDoPass, boolean isWaitForResult) {
-        log.debug("Server: RunMultipleAction invoked! [amount of actions: " + 
multipleParams.size() + "]"); //$NON-NLS-1$ //$NON-NLS-2$
+        log.debug("Server: RunMultipleAction invoked! [amount of actions: 
{}]", multipleParams.size()); //$NON-NLS-1$
 
         for (VdcActionParametersBase params : multipleParams) {
             params.setSessionId(getEngineSessionId());
@@ -192,7 +193,7 @@
         HttpServletRequest request = this.getThreadLocalRequest();
         HttpSession session = request.getSession();
 
-        log.debug("IP [" + request.getRemoteAddr() + "], Session ID [" + 
session.getId() + "]"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+        log.debug("IP '{}', Session ID '{}'", request.getRemoteAddr(), 
session.getId()); //$NON-NLS-1$
 
         return session;
     }
@@ -243,23 +244,13 @@
 
     private void debugQuery(VdcQueryType queryType, VdcQueryParametersBase 
parameters) {
         if (log.isDebugEnabled()) {
-            StringBuilder builder = new StringBuilder();
-            builder.append("Query type: "); //$NON-NLS-1$
-            builder.append(queryType);
-            builder.append(", Parameters: "); //$NON-NLS-1$
-            builder.append(parameters);
-            log.debug(builder.toString());
+            log.debug("Query type '{}', Parameters '{}'", queryType, 
parameters); //$NON-NLS-1$
         }
     }
 
     private void debugAction(VdcActionType actionType, VdcActionParametersBase 
params) {
         if (log.isDebugEnabled()) {
-            StringBuilder builder = new StringBuilder();
-            builder.append("Action type: "); //$NON-NLS-1$
-            builder.append(actionType);
-            builder.append(", Parameters: "); //$NON-NLS-1$
-            builder.append(params);
-            log.debug(builder.toString());
+            log.debug("Action type '{}', Parameters '{}'", actionType, 
params); //$NON-NLS-1$
         }
     }
 
diff --git 
a/frontend/webadmin/modules/frontend/src/main/java/org/ovirt/engine/ui/frontend/server/gwt/XsrfTokenGeneratorHttpSessionListener.java
 
b/frontend/webadmin/modules/frontend/src/main/java/org/ovirt/engine/ui/frontend/server/gwt/XsrfTokenGeneratorHttpSessionListener.java
index 14d64f6..cff9648 100644
--- 
a/frontend/webadmin/modules/frontend/src/main/java/org/ovirt/engine/ui/frontend/server/gwt/XsrfTokenGeneratorHttpSessionListener.java
+++ 
b/frontend/webadmin/modules/frontend/src/main/java/org/ovirt/engine/ui/frontend/server/gwt/XsrfTokenGeneratorHttpSessionListener.java
@@ -7,11 +7,12 @@
 import javax.servlet.http.HttpSessionEvent;
 import javax.servlet.http.HttpSessionListener;
 
-import org.apache.log4j.Logger;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 @WebListener
 public class XsrfTokenGeneratorHttpSessionListener implements 
HttpSessionListener {
-    private static final Logger log = 
Logger.getLogger(XsrfTokenGeneratorHttpSessionListener.class);
+    private static final Logger log = 
LoggerFactory.getLogger(XsrfTokenGeneratorHttpSessionListener.class);
 
     /**
      * The number of bytes in the token.
diff --git 
a/frontend/webadmin/modules/frontend/src/main/java/org/ovirt/engine/ui/frontend/server/gwt/plugin/PluginDataManager.java
 
b/frontend/webadmin/modules/frontend/src/main/java/org/ovirt/engine/ui/frontend/server/gwt/plugin/PluginDataManager.java
index 44a0b75..942c45d 100644
--- 
a/frontend/webadmin/modules/frontend/src/main/java/org/ovirt/engine/ui/frontend/server/gwt/plugin/PluginDataManager.java
+++ 
b/frontend/webadmin/modules/frontend/src/main/java/org/ovirt/engine/ui/frontend/server/gwt/plugin/PluginDataManager.java
@@ -11,13 +11,14 @@
 import java.util.Set;
 import java.util.concurrent.atomic.AtomicReference;
 
-import org.apache.log4j.Logger;
 import org.codehaus.jackson.JsonNode;
 import org.codehaus.jackson.JsonParser;
 import org.codehaus.jackson.map.ObjectMapper;
 import org.codehaus.jackson.node.ObjectNode;
 import org.ovirt.engine.core.common.config.ConfigUtil;
 import org.ovirt.engine.core.utils.EngineLocalConfig;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 /**
  * Reads, validates and stores UI plugin descriptor/configuration data.
@@ -38,7 +39,7 @@
 
     private static final long MISSING_FILE_LAST_MODIFIED = -1L;
 
-    private static final Logger logger = 
Logger.getLogger(PluginDataManager.class);
+    private static final Logger log = 
LoggerFactory.getLogger(PluginDataManager.class);
 
     /**
      * Returns UI plugin <em>data path</em>, under which UI plugin descriptor 
(JSON) files are placed.
@@ -124,7 +125,7 @@
         });
 
         if (descriptorFiles == null) {
-            logger.warn("Cannot list UI plugin descriptor files in [" + 
pluginDataDir.getAbsolutePath() + "]"); //$NON-NLS-1$ //$NON-NLS-2$
+            log.warn("Cannot list UI plugin descriptor files in '{}'", 
pluginDataDir.getAbsolutePath()); //$NON-NLS-1$
             return;
         }
 
@@ -133,7 +134,7 @@
 
         // Apply changes through reference assignment
         if (!dataMapRef.compareAndSet(currentDataMapSnapshot, 
currentDataMapCopy)) {
-            logger.warn("It seems that UI plugin data has changed, please 
reload WebAdmin application"); //$NON-NLS-1$
+            log.warn("It seems that UI plugin data has changed, please reload 
WebAdmin application"); //$NON-NLS-1$
         }
     }
 
@@ -174,28 +175,28 @@
             // Read descriptor data
             JsonNode descriptorNode = currentData != null ? 
currentData.getDescriptorNode() : null;
             if (reloadDescriptor) {
-                logger.info("Reading UI plugin descriptor [" + 
df.getAbsolutePath() + "]"); //$NON-NLS-1$ //$NON-NLS-2$
+                log.info("Reading UI plugin descriptor '{}'", 
df.getAbsolutePath()); //$NON-NLS-1$
                 descriptorNode = readJsonNode(df);
                 if (descriptorNode == null) {
                     // Failed to read descriptor data, nothing we can do about 
it
                     continue;
                 }
             } else if (descriptorNode == null) {
-                logger.warn("UI plugin descriptor node is null for [" + 
df.getAbsolutePath() + "]"); //$NON-NLS-1$ //$NON-NLS-2$
+                log.warn("UI plugin descriptor node is null for '{}'", 
df.getAbsolutePath()); //$NON-NLS-1$
                 continue;
             }
 
             // Read configuration data
             JsonNode configurationNode = currentData != null ? 
currentData.getConfigurationNode() : null;
             if (reloadConfiguration) {
-                logger.info("Reading UI plugin configuration [" + 
cf.getAbsolutePath() + "]"); //$NON-NLS-1$ //$NON-NLS-2$
+                log.info("Reading UI plugin configuration '{}'", 
cf.getAbsolutePath()); //$NON-NLS-1$
                 configurationNode = readConfigurationNode(cf);
                 if (configurationNode == null) {
                     // Failed to read configuration data, use empty object
                     configurationNode = createEmptyObjectNode();
                 }
             } else if (configurationNode == null) {
-                logger.warn("UI plugin configuration node is null for [" + 
cf.getAbsolutePath() + "]"); //$NON-NLS-1$ //$NON-NLS-2$
+                log.warn("UI plugin configuration node is null for '{}'", 
cf.getAbsolutePath()); //$NON-NLS-1$
                 continue;
             }
 
@@ -208,12 +209,12 @@
                 boolean dataValid = newData.validate(new 
PluginData.ValidationCallback() {
                     @Override
                     public void descriptorError(String message) {
-                        logger.warn("Validation error in [" + 
df.getAbsolutePath() + "]: " + message); //$NON-NLS-1$ //$NON-NLS-2$
+                        log.warn("Validation error in '{}': {}", 
df.getAbsolutePath(), message); //$NON-NLS-1$
                     }
 
                     @Override
                     public void configurationError(String message) {
-                        logger.warn("Validation error in [" + 
cf.getAbsolutePath() + "]: " + message); //$NON-NLS-1$ //$NON-NLS-2$
+                        log.warn("Validation error in '{}': {}", 
cf.getAbsolutePath(), message); //$NON-NLS-1$
                     }
                 });
                 if (!dataValid) {
@@ -251,7 +252,8 @@
         try {
             node = mapper.readValue(file, JsonNode.class);
         } catch (IOException e) {
-            logger.warn("Cannot read/parse JSON file [" + 
file.getAbsolutePath() + "]", e); //$NON-NLS-1$ //$NON-NLS-2$
+            log.warn("Cannot read/parse JSON file '{}'", 
file.getAbsolutePath()); //$NON-NLS-1$
+            log.warn("Exception", e); // $NON-NLS-1$
         }
         return node;
     }
diff --git 
a/frontend/webadmin/modules/frontend/src/main/java/org/ovirt/engine/ui/frontend/server/gwt/plugin/PluginResourceServlet.java
 
b/frontend/webadmin/modules/frontend/src/main/java/org/ovirt/engine/ui/frontend/server/gwt/plugin/PluginResourceServlet.java
index ed5525e..9d8141e 100644
--- 
a/frontend/webadmin/modules/frontend/src/main/java/org/ovirt/engine/ui/frontend/server/gwt/plugin/PluginResourceServlet.java
+++ 
b/frontend/webadmin/modules/frontend/src/main/java/org/ovirt/engine/ui/frontend/server/gwt/plugin/PluginResourceServlet.java
@@ -10,8 +10,9 @@
 import javax.servlet.http.HttpServletResponse;
 
 import org.apache.commons.lang.StringUtils;
-import org.apache.log4j.Logger;
 import org.ovirt.engine.core.utils.servlet.ServletUtils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 /**
  * Serves UI plugin static resources from local file system, relative to
@@ -25,7 +26,7 @@
 
     private static final long serialVersionUID = -8657760074902262500L;
 
-    private static final Logger logger = 
Logger.getLogger(PluginResourceServlet.class);
+    private static final Logger log = 
LoggerFactory.getLogger(PluginResourceServlet.class);
 
     private File baseDir;
 
@@ -52,7 +53,7 @@
             pluginName = parts[0];
             requestFilePath = parts[1];
         } else {
-            logger.error("Missing UI plugin name and/or relative file path for 
request [" + request.getRequestURI() + "]"); //$NON-NLS-1$ //$NON-NLS-2$
+            log.error("Missing UI plugin name and/or relative file path for 
request '{}'", request.getRequestURI()); //$NON-NLS-1$
             response.sendError(HttpServletResponse.SC_NOT_FOUND);
             return;
         }
@@ -60,11 +61,11 @@
         // Fetch and validate plugin data
         PluginData pluginData = getPluginData(pluginName);
         if (pluginData == null) {
-            logger.error("No data available for UI plugin [" + pluginName + 
"]"); //$NON-NLS-1$ //$NON-NLS-2$
+            log.error("No data available for UI plugin '{}'", pluginName); 
//$NON-NLS-1$
             response.sendError(HttpServletResponse.SC_NOT_FOUND);
             return;
         } else if (pluginData.getResourcePath() == null) {
-            logger.error("Local resource path not specified for UI plugin [" + 
pluginName + "]"); //$NON-NLS-1$ //$NON-NLS-2$
+            log.error("Local resource path not specified for UI plugin '{}'", 
pluginName); //$NON-NLS-1$
             response.sendError(HttpServletResponse.SC_NOT_FOUND);
             return;
         }
@@ -72,14 +73,14 @@
         // Locate the requested file
         String filePath = pluginData.getResourcePath() + File.separator + 
requestFilePath;
         if (!ServletUtils.isSane(filePath)) {
-            logger.error("Requested file path [" + filePath + "] is not 
sane"); //$NON-NLS-1$ //$NON-NLS-2$
+            log.error("Requested file path '{}' is not sane", filePath); 
//$NON-NLS-1$
             response.sendError(HttpServletResponse.SC_NOT_FOUND);
             return;
         }
 
         File file = new File(baseDir, filePath);
         if (file.isDirectory()) {
-            logger.error("Requested file path [" + filePath + "] denotes a 
directory instead of file"); //$NON-NLS-1$ //$NON-NLS-2$
+            log.error("Requested file path '{}' denotes a directory instead of 
file", filePath); //$NON-NLS-1$
             response.sendError(HttpServletResponse.SC_NOT_FOUND);
             return;
         }


-- 
To view, visit http://gerrit.ovirt.org/34182
To unsubscribe, visit http://gerrit.ovirt.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Iea13c66ca38380e0e6017921d135051e0342f565
Gerrit-PatchSet: 1
Gerrit-Project: ovirt-engine
Gerrit-Branch: master
Gerrit-Owner: Martin Peřina <[email protected]>
_______________________________________________
Engine-patches mailing list
[email protected]
http://lists.ovirt.org/mailman/listinfo/engine-patches

Reply via email to