RestForwarder: Tidy up debug logging

- Debug log is emitted with stack trace in both cases that the error
  is recoverable and unrecoverable. Move it out of the if-block.

- Mention the current attempt number and max retries in the error
  message, in the form "[1/5]".

- When the error is unrecoverable, mention it explicitly in the log.

- Explicitly add "giving up" in cases where the attempt is aborted.

- Since we now include the stack trace in all cases, don't include it
  on the "retrying" message.

Change-Id: Id8b0dc3a9900f7e76d265cbc2db7e61827e76de1
Signed-off-by: David Pursehouse <dpursehouse@collab.net>
diff --git a/src/main/java/com/ericsson/gerrit/plugins/highavailability/forwarder/rest/RestForwarder.java b/src/main/java/com/ericsson/gerrit/plugins/highavailability/forwarder/rest/RestForwarder.java
index 8531b9a..c1c46d9 100644
--- a/src/main/java/com/ericsson/gerrit/plugins/highavailability/forwarder/rest/RestForwarder.java
+++ b/src/main/java/com/ericsson/gerrit/plugins/highavailability/forwarder/rest/RestForwarder.java
@@ -131,22 +131,22 @@
           log.debug("{} OK", name);
           return true;
         } catch (ForwardingException e) {
-          if (e.isRecoverable()) {
-            log.debug("Failed to {}", name, e);
-          } else {
-            log.error("Failed to {}", name, e);
+          int maxTries = cfg.http().maxTries();
+          log.debug("Failed to {} [{}/{}]", name, execCnt, maxTries, e);
+          if (!e.isRecoverable()) {
+            log.error("{} failed with unrecoverable error; giving up", name);
             return false;
           }
-          if (execCnt >= cfg.http().maxTries()) {
-            log.error("Failed to {}, after {} tries", name, cfg.http().maxTries());
+          if (execCnt >= maxTries) {
+            log.error("Failed to {} after {} tries; giving up", name, maxTries);
             return false;
           }
 
-          log.debug("Retrying to {} caused by '{}'", name, e);
+          log.debug("Retrying to {}", name);
           try {
             Thread.sleep(cfg.http().retryInterval());
           } catch (InterruptedException ie) {
-            log.error("{} was interrupted, giving up", name, ie);
+            log.error("{} was interrupted; giving up", name, ie);
             Thread.currentThread().interrupt();
             return false;
           }