Rename WrappedLogger to ReplicationStateLogger

The name WrappedLogger is not very good as it does not
make it clear what is being wrapped.

Rename it to ReplicationStateLogger which better describes
it.

Change-Id: Idad7aace005c90a831cafa9c2fb52596e21cc4d7
diff --git a/src/main/java/com/googlesource/gerrit/plugins/replication/Destination.java b/src/main/java/com/googlesource/gerrit/plugins/replication/Destination.java
index 63fc350..20b0a3f 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/replication/Destination.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/replication/Destination.java
@@ -66,7 +66,7 @@
 
 class Destination {
   private static final Logger log = ReplicationQueue.log;
-  private static final WrappedLogger wrappedLog = new WrappedLogger(log);
+  private static final ReplicationStateLogger stateLog = new ReplicationStateLogger(log);
 
   private final int poolThreads;
   private final String poolName;
@@ -213,7 +213,7 @@
         return;
       }
     } catch (NoSuchProjectException err) {
-      wrappedLog.error(String.format(
+      stateLog.error(String.format(
           "source project %s not available", project), err, state);
       return;
     } catch (Exception e) {
@@ -230,7 +230,7 @@
         try {
           git = gitManager.openRepository(project);
         } catch (IOException err) {
-          wrappedLog.error(String.format(
+          stateLog.error(String.format(
               "source project %s not available", project), err, state);
           return;
         }
@@ -242,7 +242,7 @@
             return;
           }
         } catch (IOException err) {
-          wrappedLog.error(String.format(
+          stateLog.error(String.format(
               "cannot check type of project %s", project), err, state);
           return;
         } finally {
diff --git a/src/main/java/com/googlesource/gerrit/plugins/replication/PushAll.java b/src/main/java/com/googlesource/gerrit/plugins/replication/PushAll.java
index 25f4cde..165ef03 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/replication/PushAll.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/replication/PushAll.java
@@ -29,7 +29,7 @@
 
 class PushAll implements Runnable {
   private static final Logger log = LoggerFactory.getLogger(PushAll.class);
-  private static final WrappedLogger wrappedLog = new WrappedLogger(log);
+  private static final ReplicationStateLogger stateLog = new ReplicationStateLogger(log);
 
   interface Factory {
     PushAll create(String urlMatch, ReplicationState state);
@@ -62,7 +62,7 @@
         replication.scheduleFullSync(nameKey, urlMatch, state);
       }
     } catch (Exception e) {
-      wrappedLog.error("Cannot enumerate known projects", e, state);
+      stateLog.error("Cannot enumerate known projects", e, state);
     }
     state.markAllPushTasksScheduled();
   }
diff --git a/src/main/java/com/googlesource/gerrit/plugins/replication/PushOne.java b/src/main/java/com/googlesource/gerrit/plugins/replication/PushOne.java
index 39e18f4..876a4d5 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/replication/PushOne.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/replication/PushOne.java
@@ -77,7 +77,7 @@
  */
 class PushOne implements ProjectRunnable {
   private static final Logger log = ReplicationQueue.log;
-  private static final WrappedLogger wrappedLog = new WrappedLogger(log);
+  private static final ReplicationStateLogger stateLog = new ReplicationStateLogger(log);
   static final String ALL_REFS = "..all..";
 
   interface Factory {
@@ -270,7 +270,7 @@
       git = gitManager.openRepository(projectName);
       runImpl();
     } catch (RepositoryNotFoundException e) {
-      wrappedLog.error("Cannot replicate " + projectName
+      stateLog.error("Cannot replicate " + projectName
           + "; Local repository error: "
           + e.getMessage(), getStatesAsArray());
 
@@ -290,7 +290,7 @@
     } catch (NoRemoteRepositoryException e) {
       createRepository();
     } catch (NotSupportedException e) {
-      wrappedLog.error("Cannot replicate to " + uri, e, getStatesAsArray());
+      stateLog.error("Cannot replicate to " + uri, e, getStatesAsArray());
 
     } catch (TransportException e) {
       Throwable cause = e.getCause();
@@ -316,12 +316,12 @@
         pool.reschedule(this, Destination.RetryReason.TRANSPORT_ERROR);
       }
     } catch (IOException e) {
-      wrappedLog.error("Cannot replicate to " + uri, e, getStatesAsArray());
+      stateLog.error("Cannot replicate to " + uri, e, getStatesAsArray());
     } catch (RuntimeException e) {
-      wrappedLog.error("Unexpected error during replication to " + uri, e, getStatesAsArray());
+      stateLog.error("Unexpected error during replication to " + uri, e, getStatesAsArray());
 
     } catch (Error e) {
-      wrappedLog.error("Unexpected error during replication to " + uri, e, getStatesAsArray());
+      stateLog.error("Unexpected error during replication to " + uri, e, getStatesAsArray());
 
     } finally {
       if (git != null) {
@@ -351,11 +351,11 @@
         log.warn("Missing repository created; retry replication to " + uri);
         pool.reschedule(this, Destination.RetryReason.REPOSITORY_MISSING);
       } catch (IOException ioe) {
-        wrappedLog.error("Cannot replicate to " + uri + "; failed to create missing repository",
+        stateLog.error("Cannot replicate to " + uri + "; failed to create missing repository",
             ioe, getStatesAsArray());
       }
     } else {
-      wrappedLog.error("Cannot replicate to " + uri + "; repository not found", getStatesAsArray());
+      stateLog.error("Cannot replicate to " + uri + "; repository not found", getStatesAsArray());
     }
   }
 
@@ -423,7 +423,7 @@
       try {
         db = schema.open();
       } catch (OrmException e) {
-        wrappedLog.error("Cannot read database to replicate to " + projectName, e, getStatesAsArray());
+        stateLog.error("Cannot read database to replicate to " + projectName, e, getStatesAsArray());
         return Collections.emptyList();
       }
       try {
@@ -562,7 +562,7 @@
         case REJECTED_NODELETE:
         case REJECTED_NONFASTFORWARD:
         case REJECTED_REMOTE_CHANGED:
-          wrappedLog.error(String.format("Failed replicate of %s to %s: status %s",
+          stateLog.error(String.format("Failed replicate of %s to %s: status %s",
               u.getRemoteName(), uri, u.getStatus()), logStatesArray);
           pushStatus = RefPushResult.FAILED;
           anyRefFailed = true;
@@ -570,14 +570,14 @@
 
         case REJECTED_OTHER_REASON:
           if ("non-fast-forward".equals(u.getMessage())) {
-            wrappedLog.error(String.format("Failed replicate of %s to %s"
+            stateLog.error(String.format("Failed replicate of %s to %s"
                 + ", remote rejected non-fast-forward push."
                 + "  Check receive.denyNonFastForwards variable in config file"
                 + " of destination repository.", u.getRemoteName(), uri), logStatesArray);
           } else if ("failed to lock".equals(u.getMessage())) {
             throw new LockFailureException(uri, u.getMessage());
           } else {
-            wrappedLog.error(String.format(
+            stateLog.error(String.format(
                 "Failed replicate of %s to %s, reason: %s",
                 u.getRemoteName(), uri, u.getMessage()), logStatesArray);
           }
diff --git a/src/main/java/com/googlesource/gerrit/plugins/replication/ReplicationQueue.java b/src/main/java/com/googlesource/gerrit/plugins/replication/ReplicationQueue.java
index e28060b..223e597 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/replication/ReplicationQueue.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/replication/ReplicationQueue.java
@@ -61,7 +61,7 @@
     ProjectDeletedListener,
     HeadUpdatedListener {
   static final Logger log = LoggerFactory.getLogger(ReplicationQueue.class);
-  private static final WrappedLogger wrappedLog = new WrappedLogger(log);
+  private static final ReplicationStateLogger stateLog = new ReplicationStateLogger(log);
 
   static String replaceName(String in, String name, boolean keyIsOptional) {
     String key = "${name}";
@@ -111,7 +111,7 @@
   void scheduleFullSync(final Project.NameKey project, final String urlMatch,
       ReplicationState state) {
     if (!running) {
-      wrappedLog.warn("Replication plugin did not finish startup before event", state);
+      stateLog.warn("Replication plugin did not finish startup before event", state);
       return;
     }
 
@@ -128,7 +128,7 @@
   public void onGitReferenceUpdated(GitReferenceUpdatedListener.Event event) {
     ReplicationState state = new ReplicationState(new GitUpdateProcessing(changeHooks, database));
     if (!running) {
-      wrappedLog.warn("Replication plugin did not finish startup before event", state);
+      stateLog.warn("Replication plugin did not finish startup before event", state);
       return;
     }
 
diff --git a/src/main/java/com/googlesource/gerrit/plugins/replication/WrappedLogger.java b/src/main/java/com/googlesource/gerrit/plugins/replication/ReplicationStateLogger.java
similarity index 78%
rename from src/main/java/com/googlesource/gerrit/plugins/replication/WrappedLogger.java
rename to src/main/java/com/googlesource/gerrit/plugins/replication/ReplicationStateLogger.java
index 7bef7e7..cb1d4ce 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/replication/WrappedLogger.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/replication/ReplicationStateLogger.java
@@ -16,11 +16,19 @@
 
 import org.slf4j.Logger;
 
-public class WrappedLogger {
+/**
+ * Wrapper around a Logger that also logs out the replication state.
+ * <p>
+ * When logging replication errors it is useful to know the current
+ * replication state.  This utility class wraps the methods from Logger
+ * and logs additional information about the replication state to the
+ * stderr console.
+ */
+public class ReplicationStateLogger {
 
   private final Logger logger;
 
-  public WrappedLogger(Logger logger) {
+  public ReplicationStateLogger(Logger logger) {
     this.logger = logger;
   }
 
diff --git a/src/main/java/com/googlesource/gerrit/plugins/replication/StartCommand.java b/src/main/java/com/googlesource/gerrit/plugins/replication/StartCommand.java
index 9db0ac5..44513c0 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/replication/StartCommand.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/replication/StartCommand.java
@@ -38,7 +38,7 @@
 @CommandMetaData(name = "start", description = "Start replication for specific project or all projects")
 final class StartCommand extends SshCommand {
   private static final Logger log = LoggerFactory.getLogger(StartCommand.class);
-  private static final WrappedLogger wrappedLog = new WrappedLogger(log);
+  private static final ReplicationStateLogger stateLog = new ReplicationStateLogger(log);
   @Option(name = "--all", usage = "push all known projects")
   private boolean all;
 
@@ -88,10 +88,10 @@
         try {
           future.get();
         } catch (InterruptedException e) {
-          wrappedLog.error("Thread was interrupted while waiting for PushAll operation to finish", e, state);
+          stateLog.error("Thread was interrupted while waiting for PushAll operation to finish", e, state);
           return;
         } catch (ExecutionException e) {
-          wrappedLog.error("An exception was thrown in PushAll operation", e, state);
+          stateLog.error("An exception was thrown in PushAll operation", e, state);
           return;
         }
       }