Exception and Preconditions Netconf Refactoring

Change-Id: I3cb4abee2c70138e37160b68418e71bb5f52e1a5
diff --git a/protocols/netconf/ctl/src/main/java/org/onosproject/netconf/ctl/NetconfSessionImpl.java b/protocols/netconf/ctl/src/main/java/org/onosproject/netconf/ctl/NetconfSessionImpl.java
index 5369335..f6459b6 100644
--- a/protocols/netconf/ctl/src/main/java/org/onosproject/netconf/ctl/NetconfSessionImpl.java
+++ b/protocols/netconf/ctl/src/main/java/org/onosproject/netconf/ctl/NetconfSessionImpl.java
@@ -106,17 +106,16 @@
                             deviceInfo.name(), deviceInfo.password());
                 }
             } catch (IOException e) {
-                log.error("Authentication connection to device " +
-                                  deviceInfo.getDeviceId() + " failed:" +
-                                  e.getMessage());
+                log.error("Authentication connection to device {} failed: {} ",
+                                  deviceInfo.getDeviceId(), e.getMessage());
                 throw new NetconfException("Authentication connection to device " +
                                                    deviceInfo.getDeviceId() + " failed", e);
             }
 
             connectionActive = true;
             Preconditions.checkArgument(isAuthenticated,
-                                        "Authentication to device {} with username " +
-                                                "{} Failed",
+                                        "Authentication to device %s with username " +
+                                                "%s failed",
                                         deviceInfo.getDeviceId(), deviceInfo.name());
             startSshSession();
         }
@@ -132,8 +131,7 @@
             this.addDeviceOutputListener(new NetconfDeviceOutputEventListenerImpl(deviceInfo));
             sendHello();
         } catch (IOException e) {
-            log.error("Failed to create ch.ethz.ssh2.Session session:" +
-                              e.getMessage());
+            log.error("Failed to create ch.ethz.ssh2.Session session:", e);
             throw new NetconfException("Failed to create ch.ethz.ssh2.Session session with device" +
                                                deviceInfo, e);
         }
@@ -434,7 +432,7 @@
                 return true;
             }
         }
-        log.warn("Device " + deviceInfo + "has error in reply {}", reply);
+        log.warn("Device {} has error in reply {}", deviceInfo, reply);
         return false;
     }
 
@@ -445,8 +443,8 @@
             Optional<Integer> messageId = event.getMessageID();
             if (!messageId.isPresent()) {
                 errorReplies.add(event.getMessagePayload());
-                log.error("Device " + event.getDeviceInfo() +
-                          " sent error reply " + event.getMessagePayload());
+                log.error("Device {} sent error reply {}",
+                          event.getDeviceInfo(), event.getMessagePayload());
                 return;
             }
             CompletableFuture<String> completedReply =
diff --git a/protocols/netconf/ctl/src/main/java/org/onosproject/netconf/ctl/NetconfStreamThread.java b/protocols/netconf/ctl/src/main/java/org/onosproject/netconf/ctl/NetconfStreamThread.java
index 1ed3f39..f003f7b 100644
--- a/protocols/netconf/ctl/src/main/java/org/onosproject/netconf/ctl/NetconfStreamThread.java
+++ b/protocols/netconf/ctl/src/main/java/org/onosproject/netconf/ctl/NetconfStreamThread.java
@@ -202,7 +202,7 @@
                     }
                 }
             } catch (IOException e) {
-                log.warn("Error in reading from the session for device " + netconfDeviceInfo, e);
+                log.warn("Error in reading from the session for device {} ", netconfDeviceInfo, e);
                 throw new RuntimeException(new NetconfException("Error in reading from the session for device {}" +
                                                                         netconfDeviceInfo, e));
                 //TODO should we send a socket closed message to listeners ?
diff --git a/providers/netconf/device/src/main/java/org/onosproject/provider/netconf/device/impl/NetconfDeviceProvider.java b/providers/netconf/device/src/main/java/org/onosproject/provider/netconf/device/impl/NetconfDeviceProvider.java
index 0bf3493..0a9c624 100644
--- a/providers/netconf/device/src/main/java/org/onosproject/provider/netconf/device/impl/NetconfDeviceProvider.java
+++ b/providers/netconf/device/src/main/java/org/onosproject/provider/netconf/device/impl/NetconfDeviceProvider.java
@@ -145,9 +145,8 @@
     public boolean isReachable(DeviceId deviceId) {
         NetconfDevice netconfDevice = controller.getNetconfDevice(deviceId);
         if (netconfDevice == null) {
-            log.debug("Requested device id: "
-                             + deviceId.toString()
-                             + "  is not associated to any NETCONF Device");
+            log.debug("Requested device id: {} is not associated to any " +
+                              "NETCONF Device", deviceId.toString());
             return false;
         }
         return netconfDevice.isActive();