Use Logger's built-in formatting
Change-Id: I79eb533d44df45ff1e57656084c7ef4cb080fd91
This commit is contained in:
@@ -262,9 +262,9 @@ public class ApprovalsUtil {
|
||||
return changeControlFactory.controlFor(notes, user).isVisible(db);
|
||||
} catch (OrmException e) {
|
||||
log.warn(
|
||||
String.format(
|
||||
"Failed to check if account %d can see change %d",
|
||||
accountId.get(), notes.getChangeId().get()),
|
||||
"Failed to check if account {} can see change {}",
|
||||
accountId.get(),
|
||||
notes.getChangeId().get(),
|
||||
e);
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -304,9 +304,7 @@ public class StarredChangesUtil {
|
||||
.contains(label);
|
||||
} catch (IOException e) {
|
||||
log.error(
|
||||
String.format(
|
||||
"Cannot query stars by account %d on change %d", accountId.get(), changeId.get()),
|
||||
e);
|
||||
"Cannot query stars by account {} on change {}", accountId.get(), changeId.get(), e);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -333,9 +331,9 @@ public class StarredChangesUtil {
|
||||
return ref != null ? ref.getObjectId() : ObjectId.zeroId();
|
||||
} catch (IOException e) {
|
||||
log.error(
|
||||
String.format(
|
||||
"Getting star object ID for account %d on change %d failed",
|
||||
accountId.get(), changeId.get()),
|
||||
"Getting star object ID for account {} on change {} failed",
|
||||
accountId.get(),
|
||||
changeId.get(),
|
||||
e);
|
||||
return ObjectId.zeroId();
|
||||
}
|
||||
|
||||
@@ -89,8 +89,7 @@ public class AccountState {
|
||||
try {
|
||||
return HashedPassword.decode(hashedStr).checkPassword(password);
|
||||
} catch (DecoderException e) {
|
||||
logger.error(
|
||||
String.format("DecoderException for user %s: %s ", username, e.getMessage()));
|
||||
logger.error("DecoderException for user {}: {}", username, e.getMessage());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -39,11 +39,10 @@ public class CapabilityUtils {
|
||||
RequiresAnyCapability rac = getClassAnnotation(clazz, RequiresAnyCapability.class);
|
||||
if (rc != null && rac != null) {
|
||||
log.error(
|
||||
String.format(
|
||||
"Class %s uses both @%s and @%s",
|
||||
clazz.getName(),
|
||||
RequiresCapability.class.getSimpleName(),
|
||||
RequiresAnyCapability.class.getSimpleName()));
|
||||
"Class {} uses both @{} and @{}",
|
||||
clazz.getName(),
|
||||
RequiresCapability.class.getSimpleName(),
|
||||
RequiresAnyCapability.class.getSimpleName());
|
||||
throw new AuthException("cannot check capability");
|
||||
}
|
||||
CapabilityControl ctl = user.getCapabilities();
|
||||
@@ -75,9 +74,9 @@ public class CapabilityUtils {
|
||||
}
|
||||
if (rac.value().length == 0) {
|
||||
log.error(
|
||||
String.format(
|
||||
"Class %s uses @%s with no capabilities listed",
|
||||
clazz.getName(), RequiresAnyCapability.class.getSimpleName()));
|
||||
"Class {} uses @{} with no capabilities listed",
|
||||
clazz.getName(),
|
||||
RequiresAnyCapability.class.getSimpleName());
|
||||
throw new AuthException("cannot check capability");
|
||||
}
|
||||
for (String capability : rac.value()) {
|
||||
@@ -101,11 +100,10 @@ public class CapabilityUtils {
|
||||
capability = String.format("%s-%s", pluginName, capability);
|
||||
} else if (scope == CapabilityScope.PLUGIN) {
|
||||
log.error(
|
||||
String.format(
|
||||
"Class %s uses @%s(scope=%s), but is not within a plugin",
|
||||
clazz.getName(),
|
||||
RequiresCapability.class.getSimpleName(),
|
||||
CapabilityScope.PLUGIN.name()));
|
||||
"Class {} uses @{}(scope={}), but is not within a plugin",
|
||||
clazz.getName(),
|
||||
RequiresCapability.class.getSimpleName(),
|
||||
CapabilityScope.PLUGIN.name());
|
||||
throw new AuthException("cannot check capability");
|
||||
}
|
||||
return capability;
|
||||
|
||||
@@ -61,9 +61,7 @@ public class ChangeCleanupRunner implements Runnable {
|
||||
if (delay == MISSING_CONFIG && interval == MISSING_CONFIG) {
|
||||
log.info("Ignoring missing changeCleanup schedule configuration");
|
||||
} else if (delay < 0 || interval <= 0) {
|
||||
log.warn(
|
||||
String.format(
|
||||
"Ignoring invalid changeCleanup schedule configuration: %s", scheduleConfig));
|
||||
log.warn("Ignoring invalid changeCleanup schedule configuration: {}", scheduleConfig);
|
||||
} else {
|
||||
@SuppressWarnings("unused")
|
||||
Future<?> possiblyIgnoredError =
|
||||
|
||||
@@ -421,9 +421,9 @@ public class ChangeInserter implements InsertChangeOp {
|
||||
return changeControlFactory.controlFor(notes, user).isVisible(db);
|
||||
} catch (OrmException e) {
|
||||
log.warn(
|
||||
String.format(
|
||||
"Failed to check if account %d can see change %d",
|
||||
accountId.get(), notes.getChangeId().get()),
|
||||
"Failed to check if account {} can see change {}",
|
||||
accountId.get(),
|
||||
notes.getChangeId().get(),
|
||||
e);
|
||||
return false;
|
||||
}
|
||||
@@ -449,7 +449,7 @@ public class ChangeInserter implements InsertChangeOp {
|
||||
cm.addExtraCC(extraCC);
|
||||
cm.send();
|
||||
} catch (Exception e) {
|
||||
log.error("Cannot send email for new change " + change.getId(), e);
|
||||
log.error("Cannot send email for new change {}", change.getId(), e);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -232,9 +232,10 @@ public class MergeabilityCacheImpl implements MergeabilityCache {
|
||||
return cache.get(key, new Loader(key, dest, repo));
|
||||
} catch (ExecutionException | UncheckedExecutionException e) {
|
||||
log.error(
|
||||
String.format(
|
||||
"Error checking mergeability of %s into %s (%s)",
|
||||
key.commit.name(), key.into.name(), key.submitType.name()),
|
||||
"Error checking mergeability of {} into {} ({})",
|
||||
key.commit.name(),
|
||||
key.into.name(),
|
||||
key.submitType.name(),
|
||||
e.getCause());
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -70,10 +70,7 @@ public class RebaseUtil {
|
||||
} catch (RestApiException e) {
|
||||
return false;
|
||||
} catch (OrmException | IOException e) {
|
||||
log.warn(
|
||||
String.format(
|
||||
"Error checking if patch set %s on %s can be rebased", patchSet.getId(), dest),
|
||||
e);
|
||||
log.warn("Error checking if patch set {} on {} can be rebased", patchSet.getId(), dest, e);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -61,10 +61,8 @@ public class ListCapabilities implements RestReadView<ConfigResource> {
|
||||
for (String pluginName : pluginCapabilities.plugins()) {
|
||||
if (!isPluginNameSane(pluginName)) {
|
||||
log.warn(
|
||||
String.format(
|
||||
"Plugin name %s must match [A-Za-z0-9-]+ to use capabilities;"
|
||||
+ " rename the plugin",
|
||||
pluginName));
|
||||
"Plugin name {} must match [A-Za-z0-9-]+ to use capabilities;" + " rename the plugin",
|
||||
pluginName);
|
||||
continue;
|
||||
}
|
||||
for (Map.Entry<String, Provider<CapabilityDefinition>> entry :
|
||||
|
||||
@@ -350,9 +350,7 @@ public class ProjectConfigEntry {
|
||||
}
|
||||
}
|
||||
} catch (IOException | ConfigInvalidException e) {
|
||||
log.error(
|
||||
String.format("Failed to check if plugin config of project %s was updated.", p.get()),
|
||||
e);
|
||||
log.error("Failed to check if plugin config of project {} was updated.", p.get(), e);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -56,10 +56,7 @@ public class UiActions {
|
||||
try {
|
||||
view = e.getProvider().get();
|
||||
} catch (RuntimeException err) {
|
||||
log.error(
|
||||
String.format(
|
||||
"error creating view %s.%s", e.getPluginName(), e.getExportName()),
|
||||
err);
|
||||
log.error("error creating view {}.{}", e.getPluginName(), e.getExportName(), err);
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
@@ -156,9 +156,8 @@ public class AsyncReceiveCommits implements PreReceiveHook {
|
||||
TimeUnit.MILLISECONDS);
|
||||
} catch (ExecutionException e) {
|
||||
log.warn(
|
||||
String.format(
|
||||
"Error in ReceiveCommits while processing changes for project %s",
|
||||
rc.getProject().getName()),
|
||||
"Error in ReceiveCommits while processing changes for project {}",
|
||||
rc.getProject().getName(),
|
||||
e);
|
||||
rc.addError("internal error while processing changes");
|
||||
// ReceiveCommits has tried its best to catch errors, so anything at this
|
||||
|
||||
@@ -46,9 +46,13 @@ public class ConfiguredMimeTypes {
|
||||
add(typeName, path);
|
||||
} catch (PatternSyntaxException | InvalidPatternException e) {
|
||||
log.warn(
|
||||
String.format(
|
||||
"Ignoring invalid %s.%s.%s = %s in project %s: %s",
|
||||
MIMETYPE, typeName, KEY_PATH, path, projectName, e.getMessage()));
|
||||
"Ignoring invalid {}.{}.{} = {} in project {}: {}",
|
||||
MIMETYPE,
|
||||
typeName,
|
||||
KEY_PATH,
|
||||
path,
|
||||
projectName,
|
||||
e.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -220,9 +220,9 @@ public class MultiProgressMonitor {
|
||||
"(timeout %sms, cancelled)",
|
||||
TimeUnit.MILLISECONDS.convert(now - deadline, NANOSECONDS));
|
||||
log.warn(
|
||||
String.format(
|
||||
"MultiProgressMonitor worker killed after %sms" + detailMessage, //
|
||||
TimeUnit.MILLISECONDS.convert(now - overallStart, NANOSECONDS)));
|
||||
"MultiProgressMonitor worker killed after {}ms {}",
|
||||
TimeUnit.MILLISECONDS.convert(now - overallStart, NANOSECONDS),
|
||||
detailMessage);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -67,9 +67,9 @@ public class ListIncludedGroups implements RestReadView<GroupResource> {
|
||||
}
|
||||
} catch (NoSuchGroupException notFound) {
|
||||
log.warn(
|
||||
String.format(
|
||||
"Group %s no longer available, included into %s",
|
||||
u.getIncludeUUID(), rsrc.getGroup().getName()));
|
||||
"Group {} no longer available, included into {}",
|
||||
u.getIncludeUUID(),
|
||||
rsrc.getGroup().getName());
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -135,10 +135,10 @@ class AutoRegisterModules {
|
||||
}
|
||||
} catch (IOException e) {
|
||||
log.warn(
|
||||
String.format(
|
||||
"Cannot access %s from plugin %s: "
|
||||
+ "JavaScript auto-discovered plugin will not be registered",
|
||||
STATIC_INIT_JS, pluginName),
|
||||
"Cannot access {} from plugin {}: "
|
||||
+ "JavaScript auto-discovered plugin will not be registered",
|
||||
STATIC_INIT_JS,
|
||||
pluginName,
|
||||
e);
|
||||
}
|
||||
}
|
||||
@@ -156,9 +156,10 @@ class AutoRegisterModules {
|
||||
Export export = clazz.getAnnotation(Export.class);
|
||||
if (export == null) {
|
||||
log.warn(
|
||||
String.format(
|
||||
"In plugin %s asm incorrectly parsed %s with @Export(\"%s\")",
|
||||
pluginName, clazz.getName(), def.annotationValue));
|
||||
"In plugin {} asm incorrectly parsed {} with @Export(\"{}\")",
|
||||
pluginName,
|
||||
clazz.getName(),
|
||||
def.annotationValue);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -192,9 +193,7 @@ class AutoRegisterModules {
|
||||
if (listen != null) {
|
||||
listen(clazz, clazz);
|
||||
} else {
|
||||
log.warn(
|
||||
String.format(
|
||||
"In plugin %s asm incorrectly parsed %s with @Listen", pluginName, clazz.getName()));
|
||||
log.warn("In plugin {} asm incorrectly parsed {} with @Listen", pluginName, clazz.getName());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -92,9 +92,10 @@ public class JarScanner implements PluginContentScanner, AutoCloseable {
|
||||
throw new InvalidPluginException("Cannot auto-register", err);
|
||||
} catch (RuntimeException err) {
|
||||
log.warn(
|
||||
String.format(
|
||||
"Plugin %s has invalid class file %s inside of %s",
|
||||
pluginName, entry.getName(), jarFile.getName()),
|
||||
"Plugin {} has invalid class file {} inside of {}",
|
||||
pluginName,
|
||||
entry.getName(),
|
||||
jarFile.getName(),
|
||||
err);
|
||||
continue;
|
||||
}
|
||||
@@ -104,9 +105,11 @@ public class JarScanner implements PluginContentScanner, AutoCloseable {
|
||||
rawMap.put(def.annotationName, def);
|
||||
} else {
|
||||
log.warn(
|
||||
String.format(
|
||||
"Plugin %s tries to @%s(\"%s\") abstract class %s",
|
||||
pluginName, def.annotationName, def.annotationValue, def.className));
|
||||
"Plugin {} tries to @{}(\"{}\") abstract class {}",
|
||||
pluginName,
|
||||
def.annotationName,
|
||||
def.annotationValue,
|
||||
def.className);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -151,9 +154,7 @@ public class JarScanner implements PluginContentScanner, AutoCloseable {
|
||||
try {
|
||||
new ClassReader(read(jarFile, entry)).accept(def, SKIP_ALL);
|
||||
} catch (RuntimeException err) {
|
||||
log.warn(
|
||||
String.format("Jar %s has invalid class file %s", jarFile.getName(), entry.getName()),
|
||||
err);
|
||||
log.warn("Jar {} has invalid class file {}", jarFile.getName(), entry.getName(), err);
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
@@ -59,9 +59,9 @@ class PluginCleanerTask implements Runnable {
|
||||
if (0 < left) {
|
||||
long waiting = TimeUtil.nowMs() - start;
|
||||
log.warn(
|
||||
String.format(
|
||||
"%d plugins still waiting to be reclaimed after %d minutes",
|
||||
pending, TimeUnit.MILLISECONDS.toMinutes(waiting)));
|
||||
"{} plugins still waiting to be reclaimed after {} minutes",
|
||||
pending,
|
||||
TimeUnit.MILLISECONDS.toMinutes(waiting));
|
||||
attempts = Math.min(attempts + 1, 15);
|
||||
ensureScheduled();
|
||||
} else {
|
||||
|
||||
@@ -178,9 +178,7 @@ public class ServerPlugin extends Plugin {
|
||||
} else if ("restart".equalsIgnoreCase(v)) {
|
||||
return false;
|
||||
} else {
|
||||
log.warn(
|
||||
String.format(
|
||||
"Plugin %s has invalid Gerrit-ReloadMode %s; assuming restart", getName(), v));
|
||||
log.warn("Plugin {} has invalid Gerrit-ReloadMode {}; assuming restart", getName(), v);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -119,9 +119,11 @@ class ListDashboards implements RestReadView<ProjectResource> {
|
||||
setDefault));
|
||||
} catch (ConfigInvalidException e) {
|
||||
log.warn(
|
||||
String.format(
|
||||
"Cannot parse dashboard %s:%s:%s: %s",
|
||||
definingProject.getName(), ref.getName(), tw.getPathString(), e.getMessage()));
|
||||
"Cannot parse dashboard {}:{}:{}: {}",
|
||||
definingProject.getName(),
|
||||
ref.getName(),
|
||||
tw.getPathString(),
|
||||
e.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -147,7 +147,7 @@ public class ProjectCacheImpl implements ProjectCache {
|
||||
return state;
|
||||
} catch (ExecutionException e) {
|
||||
if (!(e.getCause() instanceof RepositoryNotFoundException)) {
|
||||
log.warn(String.format("Cannot read project %s", projectName.get()), e);
|
||||
log.warn("Cannot read project {}", projectName.get(), e);
|
||||
Throwables.throwIfInstanceOf(e.getCause(), IOException.class);
|
||||
throw new IOException(e);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user