Remove plugin name from logged warnings and errors

This information is already part of the package/class name that is
part of each log entry. There is no need to include the plugin name in
addition. Manually including the plugin name is erroneous since it may
be forgotten for some warning/errors.

Change-Id: I614d02343e97f239b8833fcab1062a195e80bce4
Signed-off-by: Edwin Kempin <edwin.kempin@sap.com>
diff --git a/src/main/java/com/googlesource/gerrit/plugins/importer/AccountUtil.java b/src/main/java/com/googlesource/gerrit/plugins/importer/AccountUtil.java
index 31fecd4..fe76caf 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/importer/AccountUtil.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/importer/AccountUtil.java
@@ -15,7 +15,6 @@
 package com.googlesource.gerrit.plugins.importer;
 
 import com.google.gerrit.common.errors.NoSuchAccountException;
-import com.google.gerrit.extensions.annotations.PluginName;
 import com.google.gerrit.extensions.common.AccountInfo;
 import com.google.gerrit.extensions.restapi.BadRequestException;
 import com.google.gerrit.reviewdb.client.Account;
@@ -47,7 +46,6 @@
 class AccountUtil {
   private static Logger log = LoggerFactory.getLogger(AccountUtil.class);
 
-  private final String pluginName;
   private final AccountCache accountCache;
   private final AccountManager accountManager;
   private final AuthType authType;
@@ -55,12 +53,10 @@
 
   @Inject
   public AccountUtil(
-      @PluginName String pluginName,
       AccountCache accountCache,
       AccountManager accountManager,
       AuthConfig authConfig,
       Provider<ReviewDb> db) {
-    this.pluginName = pluginName;
     this.accountCache = accountCache;
     this.accountManager = accountManager;
     this.authType = authConfig.getAuthType();
@@ -90,8 +86,8 @@
     }
     if (!Objects.equals(a.getAccount().getPreferredEmail(), acc.email)) {
       log.warn(String.format(
-          "[%s] Email mismatch for user %s: expected %s but found %s",
-          pluginName, acc.username, acc.email, a.getAccount().getPreferredEmail()));
+          "Email mismatch for user %s: expected %s but found %s",
+          acc.username, acc.email, a.getAccount().getPreferredEmail()));
     }
 
     return a.getAccount().getId();
diff --git a/src/main/java/com/googlesource/gerrit/plugins/importer/AddApprovalsStep.java b/src/main/java/com/googlesource/gerrit/plugins/importer/AddApprovalsStep.java
index a4a31ae..b5deef0 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/importer/AddApprovalsStep.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/importer/AddApprovalsStep.java
@@ -18,7 +18,6 @@
 import com.google.gerrit.common.TimeUtil;
 import com.google.gerrit.common.data.LabelType;
 import com.google.gerrit.common.errors.NoSuchAccountException;
-import com.google.gerrit.extensions.annotations.PluginName;
 import com.google.gerrit.extensions.common.AccountInfo;
 import com.google.gerrit.extensions.common.ApprovalInfo;
 import com.google.gerrit.extensions.common.ChangeInfo;
@@ -61,7 +60,6 @@
   private final Change change;
   private final ChangeInfo changeInfo;
   private final boolean resume;
-  private final String pluginName;
 
   @Inject
   public AddApprovalsStep(AccountUtil accountUtil,
@@ -69,7 +67,6 @@
       ReviewDb db,
       IdentifiedUser.GenericFactory genericUserFactory,
       ChangeControl.GenericFactory changeControlFactory,
-      @PluginName String pluginName,
       @Assisted Change change,
       @Assisted ChangeInfo changeInfo,
       @Assisted boolean resume) {
@@ -81,7 +78,6 @@
     this.change = change;
     this.changeInfo = changeInfo;
     this.resume = resume;
-    this.pluginName = pluginName;
   }
 
   void add(GerritApi api) throws OrmException, NoSuchChangeException, IOException,
@@ -101,13 +97,13 @@
           ChangeControl ctrl = control(change, a);
           LabelType labelType = ctrl.getLabelTypes().byLabel(labelName);
           if(labelType == null) {
-            log.warn(String.format("[%s] Label '%s' not found in target system."
+            log.warn(String.format("Label '%s' not found in target system."
                 + " This label was referenced by an approval provided from '%s'"
                 + " for change '%s'."
                 + " This approval will be skipped. In order to import this"
                 + " approval configure the missing label and resume the import"
                 + " with the force option."
-                , pluginName, labelName, a.username, changeInfo.id));
+                , labelName, a.username, changeInfo.id));
             continue;
           }
           short shortValue = a.value != null ? a.value.shortValue() : 0;
diff --git a/src/main/java/com/googlesource/gerrit/plugins/importer/AddHashtagsStep.java b/src/main/java/com/googlesource/gerrit/plugins/importer/AddHashtagsStep.java
index f8aaef9..f04c435 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/importer/AddHashtagsStep.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/importer/AddHashtagsStep.java
@@ -14,7 +14,6 @@
 
 package com.googlesource.gerrit.plugins.importer;
 
-import com.google.gerrit.extensions.annotations.PluginName;
 import com.google.gerrit.extensions.api.changes.HashtagsInput;
 import com.google.gerrit.extensions.common.ChangeInfo;
 import com.google.gerrit.extensions.restapi.AuthException;
@@ -47,7 +46,6 @@
   private final HashtagsUtil hashtagsUtil;
   private final CurrentUser currentUser;
   private final ChangeControl.GenericFactory changeControlFactory;
-  private final String pluginName;
   private final Change change;
   private final ChangeInfo changeInfo;
   private final boolean resume;
@@ -56,14 +54,12 @@
   AddHashtagsStep(HashtagsUtil hashtagsUtil,
       CurrentUser currentUser,
       ChangeControl.GenericFactory changeControlFactory,
-      @PluginName String pluginName,
       @Assisted Change change,
       @Assisted ChangeInfo changeInfo,
       @Assisted boolean resume) {
     this.hashtagsUtil = hashtagsUtil;
     this.currentUser = currentUser;
     this.changeControlFactory = changeControlFactory;
-    this.pluginName = pluginName;
     this.change = change;
     this.changeInfo = changeInfo;
     this.resume = resume;
@@ -85,11 +81,11 @@
       hashtagsUtil.setHashtags(ctrl, input, false, false);
     } catch (AuthException e) {
       log.warn(String.format(
-          "[%s] Hashtags cannot be set on change %s because the importing"
+          "Hashtags cannot be set on change %s because the importing"
               + " user %s doesn't have permissions to edit hashtags"
               + " (e.g. assign the 'Edit Hashtags' global capability"
               + " and resume the import with the force option).",
-          pluginName, ChangeTriplet.format(change), currentUser.getUserName()));
+          ChangeTriplet.format(change), currentUser.getUserName()));
     }
   }
 }
diff --git a/src/main/java/com/googlesource/gerrit/plugins/importer/ImportGroup.java b/src/main/java/com/googlesource/gerrit/plugins/importer/ImportGroup.java
index 6d6d7ca..4194a6c 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/importer/ImportGroup.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/importer/ImportGroup.java
@@ -17,7 +17,6 @@
 import static com.google.gerrit.reviewdb.client.AccountGroup.isInternalGroup;
 
 import com.google.gerrit.common.errors.NoSuchAccountException;
-import com.google.gerrit.extensions.annotations.PluginName;
 import com.google.gerrit.extensions.annotations.RequiresCapability;
 import com.google.gerrit.extensions.common.AccountInfo;
 import com.google.gerrit.extensions.registration.DynamicSet;
@@ -76,7 +75,6 @@
 
   private static Logger log = LoggerFactory.getLogger(ImportGroup.class);
 
-  private final String pluginName;
   private final Config cfg;
   private final ReviewDb db;
   private final AccountUtil accountUtil;
@@ -91,7 +89,6 @@
 
   @Inject
   ImportGroup(
-      @PluginName String pluginName,
       @GerritServerConfig Config cfg,
       ReviewDb db,
       AccountUtil accountUtil,
@@ -102,7 +99,6 @@
       ImportGroup.Factory importGroupFactory,
       GerritApi.Factory apiFactory,
       @Assisted AccountGroup.NameKey group) {
-    this.pluginName = pluginName;
     this.cfg = cfg;
     this.db = db;
     this.accountUtil = accountUtil;
@@ -213,8 +209,8 @@
       IOException, PreconditionFailedException, MethodNotAllowedException {
     String uniqueName = getUniqueGroupName(info.name);
     if (!info.name.equals(uniqueName)) {
-      log.warn(String.format("[%s] Group %s with UUID %s is imported with name %s",
-          pluginName, info.name, info.id, uniqueName));
+      log.warn(String.format("Group %s with UUID %s is imported with name %s",
+          info.name, info.id, uniqueName));
       info.name = uniqueName;
     }
     AccountGroup group = createAccountGroup(info);
diff --git a/src/main/java/com/googlesource/gerrit/plugins/importer/ImportProject.java b/src/main/java/com/googlesource/gerrit/plugins/importer/ImportProject.java
index ca6efb5..bc8061e 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/importer/ImportProject.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/importer/ImportProject.java
@@ -19,7 +19,6 @@
 
 import com.google.common.base.Strings;
 import com.google.gerrit.common.errors.NoSuchAccountException;
-import com.google.gerrit.extensions.annotations.PluginName;
 import com.google.gerrit.extensions.annotations.RequiresCapability;
 import com.google.gerrit.extensions.restapi.BadRequestException;
 import com.google.gerrit.extensions.restapi.ResourceConflictException;
@@ -99,7 +98,6 @@
   private static Logger log = LoggerFactory.getLogger(ImportProject.class);
   private static Version v2_11 = new Version("2.11");
 
-  private final String pluginName;
   private final ProjectCache projectCache;
   private final OpenRepositoryStep openRepoStep;
   private final ConfigureRepositoryStep configRepoStep;
@@ -124,7 +122,6 @@
 
   @Inject
   ImportProject(
-      @PluginName String pluginName,
       ProjectCache projectCache,
       OpenRepositoryStep openRepoStep,
       ConfigureRepositoryStep configRepoStep,
@@ -138,7 +135,6 @@
       ImportLog importLog,
       ProjectsCollection projects,
       @Assisted Project.NameKey targetProject) {
-    this.pluginName = pluginName;
     this.projectCache = projectCache;
     this.openRepoStep = openRepoStep;
     this.configRepoStep = configRepoStep;
@@ -257,11 +253,11 @@
       importLog.onImport((IdentifiedUser) currentUser.get(), srcProject,
           targetProject, input.from, e);
       String msg = input.from != null
-          ? format("[%s] Unable to transfer project '%s' from"
+          ? format("Unable to transfer project '%s' from"
               + " source gerrit host '%s'.",
-              pluginName, srcProject.get(), input.from)
-          : format("[%s] Unable to copy project '%s'.",
-              pluginName, srcProject.get());
+              srcProject.get(), input.from)
+          : format("Unable to copy project '%s'.",
+              srcProject.get());
       log.error(msg, e);
       throw e;
     }
diff --git a/src/main/java/com/googlesource/gerrit/plugins/importer/ReplayChangesStep.java b/src/main/java/com/googlesource/gerrit/plugins/importer/ReplayChangesStep.java
index dcebaff..6d1d388 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/importer/ReplayChangesStep.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/importer/ReplayChangesStep.java
@@ -17,7 +17,6 @@
 import com.google.common.collect.Iterators;
 import com.google.gerrit.common.Nullable;
 import com.google.gerrit.common.errors.NoSuchAccountException;
-import com.google.gerrit.extensions.annotations.PluginName;
 import com.google.gerrit.extensions.client.ChangeStatus;
 import com.google.gerrit.extensions.common.ChangeInfo;
 import com.google.gerrit.extensions.restapi.BadRequestException;
@@ -65,7 +64,6 @@
 
   private static Logger log = LoggerFactory.getLogger(ReplayChangesStep.class);
 
-  private final String pluginName;
   private final ReplayRevisionsStep.Factory replayRevisionsFactory;
   private final ReplayInlineCommentsStep.Factory replayInlineCommentsFactory;
   private final ReplayMessagesStep.Factory replayMessagesFactory;
@@ -88,7 +86,6 @@
 
   @Inject
   ReplayChangesStep(
-      @PluginName String pluginName,
       ReplayRevisionsStep.Factory replayRevisionsFactory,
       ReplayInlineCommentsStep.Factory replayInlineCommentsFactory,
       ReplayMessagesStep.Factory replayMessagesFactory,
@@ -108,7 +105,6 @@
       @Assisted("resume") boolean resume,
       @Assisted ResumeImportStatistic importStatistic,
       @Assisted ProgressMonitor pm) {
-    this.pluginName = pluginName;
     this.replayRevisionsFactory = replayRevisionsFactory;
     this.replayInlineCommentsFactory = replayInlineCommentsFactory;
     this.replayMessagesFactory = replayMessagesFactory;
@@ -142,8 +138,8 @@
         try {
           replayChange(rw, c);
         } catch (Exception e) {
-          log.error(String.format("[%s] Failed to replay change %s.",
-              pluginName, Url.decode(c.id)), e);
+          log.error(String.format("Failed to replay change %s.",
+              Url.decode(c.id)), e);
           throw e;
         }
         pm.update(1);
@@ -176,8 +172,7 @@
     }
 
     if (c.revisions.isEmpty()) {
-      log.warn(String.format("[%s] Change %s has no revisions.",
-          pluginName, c.id));
+      log.warn(String.format("Change %s has no revisions.", c.id));
       return;
     }
 
diff --git a/src/main/java/com/googlesource/gerrit/plugins/importer/ReplayInlineCommentsStep.java b/src/main/java/com/googlesource/gerrit/plugins/importer/ReplayInlineCommentsStep.java
index ec85a3a..0dda6e6 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/importer/ReplayInlineCommentsStep.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/importer/ReplayInlineCommentsStep.java
@@ -22,7 +22,6 @@
 import com.google.common.collect.Multimap;
 import com.google.gerrit.common.TimeUtil;
 import com.google.gerrit.common.errors.NoSuchAccountException;
-import com.google.gerrit.extensions.annotations.PluginName;
 import com.google.gerrit.extensions.client.Side;
 import com.google.gerrit.extensions.common.ChangeInfo;
 import com.google.gerrit.extensions.common.CommentInfo;
@@ -73,7 +72,6 @@
   private final ChangeUpdate.Factory updateFactory;
   private final PatchLineCommentsUtil plcUtil;
   private final PatchListCache patchListCache;
-  private final String pluginName;
   private final Change change;
   private final ChangeInfo changeInfo;
   private final GerritApi api;
@@ -87,7 +85,6 @@
       ChangeUpdate.Factory updateFactory,
       PatchLineCommentsUtil plcUtil,
       PatchListCache patchListCache,
-      @PluginName String pluginName,
       @Assisted Change change,
       @Assisted ChangeInfo changeInfo,
       @Assisted GerritApi api,
@@ -99,7 +96,6 @@
     this.updateFactory = updateFactory;
     this.plcUtil = plcUtil;
     this.patchListCache = patchListCache;
-    this.pluginName = pluginName;
     this.change = change;
     this.changeInfo = changeInfo;
     this.api = api;
@@ -117,20 +113,20 @@
           // it must be a revision that was created in the target system after
           // the initial import
           log.warn(String.format(
-              "[%s] Project %s was modified in target system: "
+              "Project %s was modified in target system: "
                   + "Skip replay inline comments for patch set %s"
                   + " which doesn't exist in the source system.",
-              pluginName, change.getProject().get(), ps.getId().toString()));
+              change.getProject().get(), ps.getId().toString()));
           continue;
         }
 
         comments = filterComments(ps, comments);
       } else if (comments == null) {
         log.warn(String.format(
-            "[%s] Cannot retrieve comments for revision %s, "
+            "Cannot retrieve comments for revision %s, "
                 + "revision not found in source system: "
                 + "Skip replay inline comments for patch set %s of project %s.",
-            pluginName, ps.getRevision().get(), ps.getId().toString(),
+            ps.getRevision().get(), ps.getId().toString(),
             change.getProject().get()));
         continue;
       }
diff --git a/src/main/java/com/googlesource/gerrit/plugins/importer/ReplayRevisionsStep.java b/src/main/java/com/googlesource/gerrit/plugins/importer/ReplayRevisionsStep.java
index ab9c061..a4b4601 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/importer/ReplayRevisionsStep.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/importer/ReplayRevisionsStep.java
@@ -15,7 +15,6 @@
 package com.googlesource.gerrit.plugins.importer;
 
 import com.google.gerrit.common.errors.NoSuchAccountException;
-import com.google.gerrit.extensions.annotations.PluginName;
 import com.google.gerrit.extensions.common.ChangeInfo;
 import com.google.gerrit.extensions.common.RevisionInfo;
 import com.google.gerrit.extensions.restapi.BadRequestException;
@@ -58,7 +57,6 @@
   private final AccountUtil accountUtil;
   private final ReviewDb db;
   private final PatchSetInfoFactory patchSetInfoFactory;
-  private final String pluginName;
   private final Repository repo;
   private final RevWalk rw;
   private final Change change;
@@ -68,7 +66,6 @@
   public ReplayRevisionsStep(AccountUtil accountUtil,
       ReviewDb db,
       PatchSetInfoFactory patchSetInfoFactory,
-      @PluginName String pluginName,
       @Assisted Repository repo,
       @Assisted RevWalk rw,
       @Assisted Change change,
@@ -76,7 +73,6 @@
     this.accountUtil = accountUtil;
     this.db = db;
     this.patchSetInfoFactory = patchSetInfoFactory;
-    this.pluginName = pluginName;
     this.repo = repo;
     this.rw = rw;
     this.change = change;
@@ -115,9 +111,9 @@
             // a patch set with the same number was created both in the source
             // and in the target system
             log.warn(String.format(
-                "[%s] Project %s was modified in target system: "
+                "Project %s was modified in target system: "
                     + "Skip replay revision for patch set %s.",
-                pluginName, change.getProject().get(), ps.getId().toString()));
+                change.getProject().get(), ps.getId().toString()));
             continue;
           }
         }
@@ -142,15 +138,14 @@
       if (change.currentPatchSetId() == null) {
         if (changeInfo.currentRevision != null) {
           log.warn(String.format(
-              "[%s] Current revision %s of change %s not found."
+              "Current revision %s of change %s not found."
               + " Setting lastest revision %s as current patch set.",
-              pluginName, changeInfo.currentRevision, changeInfo.id,
-              info.getRevId()));
+              changeInfo.currentRevision, changeInfo.id, info.getRevId()));
         } else {
           log.warn(String.format(
-              "[%s] Change %s has no current revision."
+              "Change %s has no current revision."
               + " Setting lastest revision %s as current patch set.",
-              pluginName, changeInfo.id, info.getRevId()));
+              changeInfo.id, info.getRevId()));
         }
         change.setCurrentPatchSet(info);
       }