replace with string format on logger

This commit is contained in:
Shinsuke Sugaya 2020-12-27 07:51:28 +09:00
parent 610b144730
commit 451352c890
26 changed files with 56 additions and 57 deletions

View file

@ -119,7 +119,7 @@ public class ScriptExecutorJob implements LaJob {
try {
task.stop();
} catch (final Exception e) {
logger.warn("Failed to stop " + jobLog, e);
logger.warn("Failed to stop {}", jobLog, e);
}
}
jobLog.setEndTime(ComponentUtil.getSystemHelper().getCurrentTimeAsLong());

View file

@ -114,7 +114,7 @@ public class AdminEsreqAction extends FessAdminAction {
}
});
} catch (final Exception e) {
logger.warn("Failed to process request file: " + form.requestFile.getFileName(), e);
logger.warn("Failed to process request file: {}", form.requestFile.getFileName(), e);
throwValidationError(messages -> messages.addErrorsInvalidHeaderForRequestFile(GLOBAL, e.getMessage()),
() -> asListHtml(this::saveToken));
}

View file

@ -241,7 +241,7 @@ public class AdminStorageAction extends FessAdminAction {
minioClient.makeBucket(args);
logger.info("Created bucket: {}", fessConfig.getStorageBucket());
} catch (final Exception e1) {
logger.warn("Failed to create bucket:" + fessConfig.getStorageBucket(), e1);
logger.warn("Failed to create bucket: {}", fessConfig.getStorageBucket(), e1);
}
} else if (logger.isDebugEnabled()) {
logger.debug("Failed to access {}", fessConfig.getStorageEndpoint(), e);

View file

@ -182,7 +182,7 @@ public class FessXpathTransformer extends XpathTransformer implements FessTransf
break;
}
} catch (final TransformerException e) {
logger.warn("Could not parse a value of " + entry.getKey() + ":" + entry.getValue(), e);
logger.warn("Could not parse a value of {}:{}", entry.getKey(), entry.getValue(), e);
}
}
@ -247,7 +247,7 @@ public class FessXpathTransformer extends XpathTransformer implements FessTransf
}
}
} catch (final TransformerException e) {
logger.warn("Could not parse a value of " + META_NAME_ROBOTS_CONTENT, e);
logger.warn("Could not parse a value of {}", META_NAME_ROBOTS_CONTENT, e);
}
}
@ -408,7 +408,7 @@ public class FessXpathTransformer extends XpathTransformer implements FessTransf
putResultDataBody(dataMap, fessConfig.getIndexFieldCache(), new String(InputStreamUtil.getBytes(is), charSet));
putResultDataBody(dataMap, fessConfig.getIndexFieldHasCache(), Constants.TRUE);
} catch (final Exception e) {
logger.warn("Failed to write a cache: " + sessionId + ":" + responseData, e);
logger.warn("Failed to write a cache: {}:{}", sessionId, responseData, e);
}
} else {
logger.debug("Content size is too large({} > {}): {}", responseData.getContentLength(),
@ -547,7 +547,7 @@ public class FessXpathTransformer extends XpathTransformer implements FessTransf
final URL u = new URL(baseUrl);
return new URL(u, canonicalUrl.startsWith(":") ? u.getProtocol() + canonicalUrl : canonicalUrl).toString();
} catch (final MalformedURLException e) {
logger.warn("Invalid canonical url: " + baseUrl + " : " + canonicalUrl, e);
logger.warn("Invalid canonical url: {} : {}", baseUrl, canonicalUrl, e);
}
return null;
}
@ -694,7 +694,7 @@ public class FessXpathTransformer extends XpathTransformer implements FessTransf
buf.append("\n");
}
} catch (final Exception e) {
logger.warn("Could not parse a value of " + xpath, e);
logger.warn("Could not parse a value of {}", xpath, e);
}
return buf.toString().trim();
}
@ -865,7 +865,7 @@ public class FessXpathTransformer extends XpathTransformer implements FessTransf
return firstThumbnailUrl;
}
} catch (final Exception e) {
logger.warn("Failed to retrieve thumbnail url from " + responseData.getUrl(), e);
logger.warn("Failed to retrieve thumbnail url from {}", responseData.getUrl(), e);
}
return null;
}

View file

@ -67,7 +67,7 @@ public class DictionaryManager {
}
}
} catch (final Exception e) {
logger.warn("Failed to load " + fileMap, e);
logger.warn("Failed to load {}", fileMap, e);
}
return null;
}).filter(file -> file != null).toArray(n -> new DictionaryFile<?>[n]);

View file

@ -110,7 +110,7 @@ public class DataStoreFactory {
}
}
} catch (final Exception e) {
logger.warn("Failed to load " + jarFile.getAbsolutePath(), e);
logger.warn("Failed to load {}", jarFile.getAbsolutePath(), e);
}
}
return nameSet.stream().sorted().collect(Collectors.toList());

View file

@ -120,7 +120,7 @@ public class CrawlingConfigHelper {
}
});
} catch (final ExecutionException e) {
logger.warn("Failed to access a crawling config cache: " + configId, e);
logger.warn("Failed to access a crawling config cache: {}", configId, e);
return null;
}
}

View file

@ -215,7 +215,7 @@ public class DataIndexHelper {
try {
dataStore.store(dataConfig, indexUpdateCallback, initParamMap);
} catch (final Throwable e) {
logger.error("Failed to process a data crawling: " + dataConfig.getName(), e);
logger.error("Failed to process a data crawling: {}", dataConfig.getName(), e);
ComponentUtil.getComponent(FailureUrlService.class).store(dataConfig, e.getClass().getCanonicalName(),
dataConfig.getConfigId() + ":" + dataConfig.getName(), e);
} finally {
@ -247,7 +247,7 @@ public class DataIndexHelper {
final long numOfDeleted = fessEsClient.deleteByQuery(index, queryBuilder);
logger.info("Deleted {} old docs.", numOfDeleted);
} catch (final Exception e) {
logger.error("Could not delete old docs at " + dataConfig, e);
logger.error("Could not delete old docs at {}", dataConfig, e);
}
}

View file

@ -248,7 +248,7 @@ public class DocumentHelper {
}
return SIMILAR_DOC_HASH_PREFIX + Base64.getUrlEncoder().withoutPadding().encodeToString(baos.toByteArray());
} catch (final IOException e) {
logger.warn("Failed to encode " + hash, e);
logger.warn("Failed to encode {}", hash, e);
}
}
return hash;

View file

@ -152,8 +152,8 @@ public class LabelTypeHelper {
try {
list.add(new LabelTypePattern(labelType.getValue(), includedPaths, excludedPaths));
} catch (final Exception e) {
logger.warn("Failed to create a matching pattern of a label: " + labelType.getValue() + ", includedPaths:"
+ includedPaths + ", excludedPaths:" + excludedPaths, e);
logger.warn("Failed to create a matching pattern of a label: {}, includedPaths:{}, excludedPaths:{}",
labelType.getValue(), includedPaths, excludedPaths, e);
}
}
}

View file

@ -146,7 +146,7 @@ public class PluginHelper {
}
}
} catch (final Exception e) {
logger.warn("Failed to parse " + pluginUrl + "maven-metadata.xml.", e);
logger.warn("Failed to parse {}maven-metadata.xml.", pluginUrl, e);
}
}
return list;

View file

@ -111,7 +111,7 @@ public class SuggestHelper {
try {
suggester.settings().array().add(SuggestSettings.DefaultKeys.SUPPORTED_FIELDS, field);
} catch (final SuggestSettingsException e) {
logger.warn("Failed to add " + field, e);
logger.warn("Failed to add {}", field, e);
}
}));
suggester.createIndexIfNothing();

View file

@ -331,8 +331,7 @@ public class SystemHelper {
try {
Files.copy(baseJspFile.toPath(), jspFile.toPath());
} catch (final IOException ex) {
logger.warn("Could not copy from " + baseJspFile.getAbsolutePath() + " to " + jspFile.getAbsolutePath(),
ex);
logger.warn("Could not copy from {} to {}", baseJspFile.getAbsolutePath(), jspFile.getAbsolutePath(), ex);
}
}
});

View file

@ -117,12 +117,12 @@ public class ThemeHelper {
try {
Files.delete(f);
} catch (final IOException e) {
logger.warn("Failed to delete " + f, e);
logger.warn("Failed to delete {}", f, e);
}
});
Files.deleteIfExists(dir);
} catch (final IOException e) {
logger.warn("Failed to delete " + dir, e);
logger.warn("Failed to delete {}", dir, e);
}
}

View file

@ -361,7 +361,7 @@ public class ViewHelper {
url = URLDecoder.decode(url.replace("+", "%2B"), urlLinkEncoding);
} catch (final Exception e) {
if (logger.isDebugEnabled()) {
logger.warn("Failed to decode " + url, e);
logger.warn("Failed to decode {}", url, e);
}
}
}
@ -712,7 +712,7 @@ public class ViewHelper {
final String encodedName = URLEncoder.encode(name, Constants.UTF_8).replace("+", "%20");
response.header(CONTENT_DISPOSITION, contentDispositionType + "; filename=\"" + name + "\"; filename*=utf-8''" + encodedName);
} catch (final Exception e) {
logger.warn("Failed to write a filename: " + responseData, e);
logger.warn("Failed to write a filename: {}", responseData, e);
}
}

View file

@ -450,7 +450,7 @@ public class WebFsIndexHelper {
// clear url filter
urlFilterService.delete(sid);
} catch (final Exception e) {
logger.warn("Failed to delete UrlFilter for " + sid, e);
logger.warn("Failed to delete UrlFilter for {}", sid, e);
}
try {
@ -458,14 +458,14 @@ public class WebFsIndexHelper {
urlQueueService.clearCache();
urlQueueService.delete(sid);
} catch (final Exception e) {
logger.warn("Failed to delete UrlQueue for " + sid, e);
logger.warn("Failed to delete UrlQueue for {}", sid, e);
}
try {
// clear
dataService.delete(sid);
} catch (final Exception e) {
logger.warn("Failed to delete AccessResult for " + sid, e);
logger.warn("Failed to delete AccessResult for {}", sid, e);
}
}

View file

@ -142,17 +142,17 @@ public class IndexUpdater extends Thread {
try {
urlFilterService.delete(sessionId);
} catch (final Exception e) {
logger.warn("Failed to delete url filters: " + sessionId, e);
logger.warn("Failed to delete url filters: {}", sessionId, e);
}
try {
urlQueueService.delete(sessionId);
} catch (final Exception e) {
logger.warn("Failed to delete url queues: " + sessionId, e);
logger.warn("Failed to delete url queues: {}", sessionId, e);
}
try {
dataService.delete(sessionId);
} catch (final Exception e) {
logger.warn("Failed to delete data: " + sessionId, e);
logger.warn("Failed to delete data: {}", sessionId, e);
}
}
@ -258,7 +258,7 @@ public class IndexUpdater extends Thread {
throw e;
}
errorCount++;
logger.warn("Failed to access data. Retry to access.. " + errorCount, e);
logger.warn("Failed to access data. Retry to access it {} times.", errorCount, e);
} finally {
if (systemHelper.isForceStop()) {
finishCrawling = true;
@ -386,7 +386,7 @@ public class IndexUpdater extends Thread {
logger.debug("The number of an added document is {}.", documentSize);
}
} catch (final Exception e) {
logger.warn("Could not add a doc: " + accessResult.getUrl(), e);
logger.warn("Could not add a doc: {}", accessResult.getUrl(), e);
}
} else {
if (logger.isDebugEnabled()) {

View file

@ -39,7 +39,7 @@ public class PurgeDocJob {
fessEsClient.deleteByQuery(fessConfig.getIndexDocumentUpdateIndex(), queryBuilder);
} catch (final Exception e) {
logger.error("Could not delete expired documents: " + queryBuilder.toString(), e);
logger.error("Could not delete expired documents: {}", queryBuilder.toString(), e);
resultBuf.append(e.getMessage()).append("\n");
}

View file

@ -62,7 +62,7 @@ public class UpdateLabelJob {
return builder.setScript(script);
}
} catch (final Exception e) {
logger.warn("Failed to process " + hit, e);
logger.warn("Failed to process {}", hit, e);
}
return null;
});

View file

@ -265,7 +265,7 @@ public class ThumbnailManager {
logger.debug("No image file exists: {}", noImageFile.getAbsolutePath());
}
} catch (final Exception e) {
logger.warn("Failed to create thumbnail for " + entity, e);
logger.warn("Failed to create thumbnail for {}", entity, e);
}
}
@ -416,7 +416,7 @@ public class ThumbnailManager {
parent = parent.getParent();
}
} catch (final IOException e) {
logger.warn("Failed to delete " + path, e);
logger.warn("Failed to delete {}", path, e);
}
}
@ -456,7 +456,7 @@ public class ThumbnailManager {
@Override
public FileVisitResult visitFileFailed(final Path file, final IOException e) throws IOException {
if (e != null) {
logger.warn("I/O exception on " + file, e);
logger.warn("I/O exception on {}", file, e);
}
return FileVisitResult.CONTINUE;
}
@ -464,7 +464,7 @@ public class ThumbnailManager {
@Override
public FileVisitResult postVisitDirectory(final Path dir, final IOException e) throws IOException {
if (e != null) {
logger.warn("I/O exception on " + dir, e);
logger.warn("I/O exception on {}", dir, e);
}
deleteEmptyDirectory(dir);
return FileVisitResult.CONTINUE;
@ -507,7 +507,7 @@ public class ThumbnailManager {
Files.move(path, newPath);
logger.info("Move {} to {}", path, newPath);
} catch (final IOException e) {
logger.warn("Failed to move " + path, e);
logger.warn("Failed to move {}", path, e);
}
}
});

View file

@ -154,7 +154,7 @@ public abstract class BaseThumbnailGenerator implements ThumbnailGenerator {
ComponentUtil.getIndexingHelper().updateDocument(ComponentUtil.getFessEsClient(), thumbnailId,
fessConfig.getIndexFieldThumbnail(), value);
} catch (final Exception e) {
logger.warn("Failed to update thumbnail field at " + thumbnailId, e);
logger.warn("Failed to update thumbnail field at {}", thumbnailId, e);
}
}
@ -181,10 +181,10 @@ public abstract class BaseThumbnailGenerator implements ThumbnailGenerator {
if (e.getCause() == null) {
logger.debug(e.getMessage());
} else {
logger.warn("Failed to process " + id, e);
logger.warn("Failed to process {}", id, e);
}
} catch (final Exception e) {
logger.warn("Failed to process " + id, e);
logger.warn("Failed to process {}", id, e);
}
return false;
}

View file

@ -164,7 +164,7 @@ public class CommandGenerator extends BaseThumbnailGenerator {
p.destroy();
}
} catch (final Exception e) {
logger.warn("Failed to generate a thumbnail of " + thumbnailId, e);
logger.warn("Failed to generate a thumbnail of {}", thumbnailId, e);
}
if (task != null) {
task.cancel();

View file

@ -109,10 +109,10 @@ public class HtmlTagBasedGenerator extends BaseThumbnailGenerator {
}
} catch (final Throwable t) {
if (logger.isDebugEnabled()) {
logger.warn("Failed to create thumbnail: " + thumbnailId + " -> " + responseData.getUrl(), t);
logger.warn("Failed to create thumbnail: {} -> {}", thumbnailId, responseData.getUrl(), t);
} else {
logger.warn("Failed to create thumbnail: " + thumbnailId + " -> " + responseData.getUrl() + " ("
+ t.getClass().getCanonicalName() + ": " + t.getMessage() + ")");
logger.warn("Failed to create thumbnail: {} -> {} ({}:{})", thumbnailId, responseData.getUrl(),
t.getClass().getCanonicalName(), t.getMessage());
}
} finally {
if (!created) {

View file

@ -43,7 +43,7 @@ public final class GroovyUtil {
} catch (final JobProcessingException e) {
throw e;
} catch (final Exception e) {
logger.warn("Failed to evalue groovy script: " + template + " => " + paramMap, e);
logger.warn("Failed to evalue groovy script: {} => {}", template, paramMap, e);
return null;
} finally {
final GroovyClassLoader loader = groovyShell.getClassLoader();

View file

@ -58,7 +58,7 @@ public class ThreadDumpUtil {
}
});
} catch (final Exception e) {
logger.warn("Failed to write a thread dump to " + file, e);
logger.warn("Failed to write a thread dump to {}", file, e);
}
}

View file

@ -58,7 +58,7 @@ public final class UpgradeUtil {
}
}
} catch (final Exception e) {
logger.warn("Failed to register " + filePath, e);
logger.warn("Failed to register {}", filePath, e);
}
return false;
}
@ -83,7 +83,7 @@ public final class UpgradeUtil {
} catch (final ResourceNotFoundRuntimeException e) {
// ignore
} catch (final Exception e) {
logger.warn(aliasConfigPath + " is not found.", e);
logger.warn("{} is not found.", aliasConfigPath, e);
}
return false;
}
@ -100,7 +100,7 @@ public final class UpgradeUtil {
try {
source = FileUtil.readUTF8(mappingFile);
} catch (final Exception e) {
logger.warn(mappingFile + " is not found.", e);
logger.warn("{} is not found.", mappingFile, e);
}
try {
final AcknowledgedResponse putMappingResponse = indicesClient.preparePutMapping(index).setSource(source, XContentType.JSON)
@ -113,7 +113,7 @@ public final class UpgradeUtil {
}
// TODO bulk
} catch (final Exception e) {
logger.warn("Failed to create " + index + "/" + type + " mapping.", e);
logger.warn("Failed to create {}/{} mapping.", index, type, e);
}
}
return false;
@ -134,7 +134,7 @@ public final class UpgradeUtil {
return true;
}
} catch (final Exception e) {
logger.warn("Failed to add " + field + " to " + index + "/" + type, e);
logger.warn("Failed to add {} to {}/{} ", field, index, type, e);
}
}
return false;
@ -154,7 +154,7 @@ public final class UpgradeUtil {
return true;
}
} catch (final Exception e) {
logger.warn("Failed to update " + index + " settings.", e);
logger.warn("Failed to update {} settings.", index, e);
}
return false;
@ -166,7 +166,7 @@ public final class UpgradeUtil {
fessEsClient.index(indexRequest).actionGet();
return true;
} catch (final Exception e) {
logger.warn("Failed to add " + id + " to " + index, e);
logger.warn("Failed to add {} to {}", id, index, e);
}
return false;
}
@ -196,7 +196,7 @@ public final class UpgradeUtil {
@Override
public void onFailure(final Exception e) {
logger.warn("Failed to delete " + index + " index.", e);
logger.warn("Failed to delete {} index.", index, e);
}
});
}