Alon Bar-Lev has uploaded a new change for review.

Change subject: uutils: remove usage of commons-logging
......................................................................

uutils: remove usage of commons-logging

Bug-Url: https://bugzilla.redhat.com/show_bug.cgi?id=1109871
Change-Id: Ie79052db8ec6e1f8bf99a5f9bc9bfa065d7ee2c8
Signed-off-by: Alon Bar-Lev <[email protected]>
---
M 
backend/manager/modules/uutils/src/main/java/org/ovirt/engine/core/uutils/config/ShellLikeConfd.java
M 
backend/manager/modules/uutils/src/main/java/org/ovirt/engine/core/uutils/ssh/SSHClient.java
M 
backend/manager/modules/uutils/src/main/java/org/ovirt/engine/core/uutils/ssh/SSHDialog.java
M 
backend/manager/modules/uutils/src/main/modules/org/ovirt/engine/core/uutils/main/module.xml
M 
backend/manager/modules/uutils/src/test/java/org/ovirt/engine/core/uutils/ssh/TestCommon.java
5 files changed, 38 insertions(+), 47 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/81/34081/1

diff --git 
a/backend/manager/modules/uutils/src/main/java/org/ovirt/engine/core/uutils/config/ShellLikeConfd.java
 
b/backend/manager/modules/uutils/src/main/java/org/ovirt/engine/core/uutils/config/ShellLikeConfd.java
index acc30db..92befca 100644
--- 
a/backend/manager/modules/uutils/src/main/java/org/ovirt/engine/core/uutils/config/ShellLikeConfd.java
+++ 
b/backend/manager/modules/uutils/src/main/java/org/ovirt/engine/core/uutils/config/ShellLikeConfd.java
@@ -19,8 +19,8 @@
 import java.util.regex.Pattern;
 
 import org.apache.commons.lang.StringUtils;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 /**
  * Shell like configuration file parsing.
@@ -44,7 +44,7 @@
  * </pre>{@code}
  */
 public class ShellLikeConfd {
-    private static final Log log = LogFactory.getLog(ShellLikeConfd.class);
+    private static final Logger log = 
LoggerFactory.getLogger(ShellLikeConfd.class);
 
     private static final String SENSITIVE_KEYS = "SENSITIVE_KEYS";
 
@@ -144,7 +144,7 @@
                 if (!sensitiveKeys.contains(key)) {
                     value = values.get(key);
                 }
-                log.info("Value of property \"" + key + "\" is \"" + value + 
"\".");
+                log.info("Value of property '{}' is '{}'.", key, value);
             }
         }
     }
@@ -159,7 +159,7 @@
     private void loadProperties(File file) throws IOException {
         // Do nothing if the file doesn't exist or isn't readable:
         if (!file.canRead()) {
-            log.info("The file \"" + file.getAbsolutePath() + "\" doesn't 
exist or isn't readable. Will return an empty set of properties.");
+            log.info("The file '{}' doesn't exist or isn't readable. Will 
return an empty set of properties.", file.getAbsolutePath());
             return;
         }
 
@@ -173,7 +173,7 @@
                 index++;
                 loadLine(line);
             }
-            log.info("Loaded file \"" + file.getAbsolutePath() + "\".");
+            log.info("Loaded file '{}'.", file.getAbsolutePath());
         }
         catch (Exception e) {
             String msg = String.format(
diff --git 
a/backend/manager/modules/uutils/src/main/java/org/ovirt/engine/core/uutils/ssh/SSHClient.java
 
b/backend/manager/modules/uutils/src/main/java/org/ovirt/engine/core/uutils/ssh/SSHClient.java
index 860678f..9f17115 100644
--- 
a/backend/manager/modules/uutils/src/main/java/org/ovirt/engine/core/uutils/ssh/SSHClient.java
+++ 
b/backend/manager/modules/uutils/src/main/java/org/ovirt/engine/core/uutils/ssh/SSHClient.java
@@ -25,8 +25,8 @@
 
 import org.apache.commons.codec.DecoderException;
 import org.apache.commons.codec.binary.Hex;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 import org.apache.sshd.ClientChannel;
 import org.apache.sshd.ClientSession;
@@ -43,7 +43,7 @@
     private static final int THREAD_JOIN_WAIT_TIME = 2000;
     private static final int DEFAULT_SSH_PORT = 22;
 
-    private static final Log log = LogFactory.getLog(SSHClient.class);
+    private static final Logger log = LoggerFactory.getLogger(SSHClient.class);
 
     private SshClient _client;
     private ClientSession _session;
@@ -260,7 +260,7 @@
      */
     public void connect() throws Exception {
 
-        log.debug(String.format("Connecting: '%1$s'", this.getDisplayHost()));
+        log.debug("Connecting '{}'", this.getDisplayHost());
 
         try {
             _client = _createSshClient();
@@ -327,7 +327,7 @@
             throw e;
         }
 
-        log.debug(String.format("Connected: '%1$s'", this.getDisplayHost()));
+        log.debug("Connected: '{}'", this.getDisplayHost());
     }
 
     /**
@@ -335,7 +335,7 @@
      */
     public void authenticate() throws Exception {
 
-        log.debug(String.format("Authenticating: '%1$s'", 
this.getDisplayHost()));
+        log.debug("Authenticating: '{}'", this.getDisplayHost());
 
         try {
             AuthFuture afuture;
@@ -380,7 +380,7 @@
             throw e;
         }
 
-        log.debug(String.format("Authenticated: '%1$s'", 
this.getDisplayHost()));
+        log.debug("Authenticated: '{}'", this.getDisplayHost());
     }
 
     /**
@@ -419,7 +419,7 @@
         OutputStream err
     ) throws Exception {
 
-        log.debug(String.format("Executing: '%1$s'", command));
+        log.debug("Executing: '{}'", command);
 
         InputStream _xin = null;
         OutputStream _xout = null;
@@ -571,7 +571,7 @@
             }
         }
 
-        log.debug(String.format("Executed: '%1$s'", command));
+        log.debug("Executed: '{}'", command);
     }
 
     /**
@@ -592,7 +592,7 @@
         String file2
     ) throws Exception {
 
-        log.debug(String.format("Sending: '%1$s' '%2$s", file1, file2));
+        log.debug("Sending: '{}' '{}'", file1, file2);
 
         _remoteFileName(file2);
 
@@ -654,7 +654,7 @@
             }
         }
 
-        log.debug(String.format("Sent: '%1$s' '%2$s", file1, file2));
+        log.debug("Sent: '{}' '{}'", file1, file2);
     }
 
     /**
@@ -674,7 +674,7 @@
         String file2
     ) throws Exception {
 
-        log.debug(String.format("Receiving: '%1$s' '%2$s", file1, file2));
+        log.debug("Receiving: '{}' '{}'", file1, file2);
 
         _remoteFileName(file1);
 
@@ -737,6 +737,6 @@
             }
         }
 
-        log.debug(String.format("Received: '%1$s' '%2$s", file1, file2));
+        log.debug("Received: '{}' '{}'", file1, file2);
     }
 }
diff --git 
a/backend/manager/modules/uutils/src/main/java/org/ovirt/engine/core/uutils/ssh/SSHDialog.java
 
b/backend/manager/modules/uutils/src/main/java/org/ovirt/engine/core/uutils/ssh/SSHDialog.java
index 6a32f80..88b186e 100644
--- 
a/backend/manager/modules/uutils/src/main/java/org/ovirt/engine/core/uutils/ssh/SSHDialog.java
+++ 
b/backend/manager/modules/uutils/src/main/java/org/ovirt/engine/core/uutils/ssh/SSHDialog.java
@@ -16,8 +16,8 @@
 import java.util.LinkedList;
 import java.util.List;
 
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 /**
  * SSH dialog to be used with SSHClient class.
@@ -77,7 +77,7 @@
         public void stop();
     }
 
-    private static final Log log = LogFactory.getLog(SSHDialog.class);
+    private static final Logger log = LoggerFactory.getLogger(SSHDialog.class);
 
     private String _host;
     private int _port;
@@ -219,17 +219,13 @@
      * After connection host fingerprint can be acquired.
      */
     public void connect() throws Exception {
-        if (log.isDebugEnabled()) {
-            log.debug(
-                String.format(
-                    "connect enter (%1$s:%2$s, %3$d, %4$d)",
-                    _host,
-                    _port,
-                    _hardTimeout,
-                    _softTimeout
-                )
-            );
-        }
+        log.debug(
+            "connect enter ({}:{}, {}, {})",
+            _host,
+            _port,
+            _hardTimeout,
+            _softTimeout
+        );
 
         try {
             if (_client != null) {
@@ -250,12 +246,10 @@
         }
         catch(Exception e) {
             log.debug(
-                String.format(
-                    "Could not connect to host %1$s",
-                    _client.getDisplayHost()
-                ),
-                e
+                "Could not connect to host '{}'",
+                _client.getDisplayHost()
             );
+            log.debug("Exception", e);
             throw e;
         }
     }
@@ -282,7 +276,7 @@
         InputStream initial[]
     ) throws Exception {
 
-        log.info(String.format("SSH execute %1$s '%2$s'", 
_client.getDisplayHost(), command));
+        log.info("SSH execute '{}' '{}'", _client.getDisplayHost(), command);
 
         try (
             final PipedInputStream pinStdin = new 
PipedInputStream(BUFFER_SIZE);
@@ -345,13 +339,12 @@
             }
             catch (Exception e) {
                 log.error(
-                    String.format(
-                        "SSH error running command %1$s:'%2$s'",
-                        _client.getDisplayHost(),
-                        command
-                    ),
-                    e
+                    "SSH error running command {}:'{}': {}",
+                    _client.getDisplayHost(),
+                    command,
+                    e.getMessage()
                 );
+                log.error("Exception", e);
                 throw e;
             }
             finally {
diff --git 
a/backend/manager/modules/uutils/src/main/modules/org/ovirt/engine/core/uutils/main/module.xml
 
b/backend/manager/modules/uutils/src/main/modules/org/ovirt/engine/core/uutils/main/module.xml
index 1b364ea..07eea31 100644
--- 
a/backend/manager/modules/uutils/src/main/modules/org/ovirt/engine/core/uutils/main/module.xml
+++ 
b/backend/manager/modules/uutils/src/main/modules/org/ovirt/engine/core/uutils/main/module.xml
@@ -11,7 +11,6 @@
     <module name="javax.servlet.api"/>
     <module name="org.apache.commons.codec"/>
     <module name="org.apache.commons.lang"/>
-    <module name="org.apache.commons.logging"/>
     <module name="org.apache.sshd"/>
     <module name="org.slf4j"/>
   </dependencies>
diff --git 
a/backend/manager/modules/uutils/src/test/java/org/ovirt/engine/core/uutils/ssh/TestCommon.java
 
b/backend/manager/modules/uutils/src/test/java/org/ovirt/engine/core/uutils/ssh/TestCommon.java
index d8beaef..771502e 100644
--- 
a/backend/manager/modules/uutils/src/test/java/org/ovirt/engine/core/uutils/ssh/TestCommon.java
+++ 
b/backend/manager/modules/uutils/src/test/java/org/ovirt/engine/core/uutils/ssh/TestCommon.java
@@ -6,7 +6,6 @@
  *
  * Standalone testing:
  *  $ mkdir t
- *  $ cp 
~/.m2/repository/commons-logging/commons-logging/1.1.1/commons-logging-1.1.1.jar
  *  $ cp ~/.m2/repository/junit/junit/4.8.1/junit-4.8.1.jar t/
  *  $ cp ~/.m2/repository/org/apache/mina/mina-core/2.0.4/mina-core-2.0.4.jar 
t/
  *  $ cp ~/.m2/repository/org/apache/sshd/sshd-core/0.7.0/sshd-core-0.7.0.jar 
t/


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

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ie79052db8ec6e1f8bf99a5f9bc9bfa065d7ee2c8
Gerrit-PatchSet: 1
Gerrit-Project: ovirt-engine
Gerrit-Branch: master
Gerrit-Owner: Alon Bar-Lev <[email protected]>
_______________________________________________
Engine-patches mailing list
[email protected]
http://lists.ovirt.org/mailman/listinfo/engine-patches

Reply via email to