diff --git a/src/main/java/org/jbake/app/Asset.java b/src/main/java/org/jbake/app/Asset.java index 1c39920b4..320ab4baa 100644 --- a/src/main/java/org/jbake/app/Asset.java +++ b/src/main/java/org/jbake/app/Asset.java @@ -66,15 +66,11 @@ private void copy(File sourceFolder, File targetFolder, final FileFilter filter) for (File asset : assets) { final File target = new File(targetFolder, asset.getName()); if (asset.isFile()) { - final StringBuilder sb = new StringBuilder(); - sb.append("Copying [").append(asset.getPath()).append("]... "); try { FileUtils.copyFile(asset, target); - sb.append("done!"); - LOGGER.info(sb.toString()); + LOGGER.info("Copying [{}]... done!", asset.getPath()); } catch (IOException e) { - sb.append("failed!"); - LOGGER.error(sb.toString(), e); + LOGGER.error("Copying [{}]... failed!", asset.getPath(), e); errors.add(e); } } else if (asset.isDirectory()) { diff --git a/src/main/java/org/jbake/app/ConfigUtil.java b/src/main/java/org/jbake/app/ConfigUtil.java index 66409e754..712726500 100644 --- a/src/main/java/org/jbake/app/ConfigUtil.java +++ b/src/main/java/org/jbake/app/ConfigUtil.java @@ -253,8 +253,8 @@ public static CompositeConfiguration load(File source, boolean isRunServer) thro public static void displayLegacyConfigFileWarningIfRequired() { if (LEGACY_CONFIG_FILE_EXISTS) { if (!LEGACY_CONFIG_FILE_WARNING_SHOWN) { - LOGGER.warn(String.format("You have defined a part of your JBake configuration in %s", LEGACY_CONFIG_FILE)); - LOGGER.warn(String.format("Usage of this file is being deprecated, please rename this file to: %s to remove this warning", CONFIG_FILE)); + LOGGER.warn("You have defined a part of your JBake configuration in " + LEGACY_CONFIG_FILE); + LOGGER.warn("Usage of this file is being deprecated, please rename this file to: " + CONFIG_FILE + " to remove this warning"); LEGACY_CONFIG_FILE_WARNING_SHOWN = true; } } diff --git a/src/main/java/org/jbake/app/Crawler.java b/src/main/java/org/jbake/app/Crawler.java index a4ed109d4..e1767da2c 100644 --- a/src/main/java/org/jbake/app/Crawler.java +++ b/src/main/java/org/jbake/app/Crawler.java @@ -112,7 +112,7 @@ public void crawl(File path) { if (process) { // new or updated crawlSourceFile(sourceFile, sha1, uri); } - LOGGER.info(sb.toString()); + LOGGER.info("{}", sb); } if (sourceFile.isDirectory()) { crawl(sourceFile); @@ -208,7 +208,7 @@ private void crawlSourceFile(final File sourceFile, final String sha1, final Str ODocument doc = new ODocument(documentType); doc.fromMap(fileContents); - boolean cached = fileContents.get(DocumentAttributes.CACHED) != null ? Boolean.valueOf((String) fileContents.get(DocumentAttributes.CACHED)) : true; + boolean cached = fileContents.get(String.valueOf(DocumentAttributes.CACHED)) != null ? Boolean.valueOf((String) fileContents.get(String.valueOf(DocumentAttributes.CACHED))) : true; doc.field(String.valueOf(DocumentAttributes.CACHED), cached); doc.save(); } else { diff --git a/src/main/java/org/jbake/app/Renderer.java b/src/main/java/org/jbake/app/Renderer.java index f6193f020..4f89f98d0 100644 --- a/src/main/java/org/jbake/app/Renderer.java +++ b/src/main/java/org/jbake/app/Renderer.java @@ -198,21 +198,17 @@ public void render(Map content) throws Exception { } File outputFile = new File(outputFilename + FileUtil.findExtension(config, docType)); - StringBuilder sb = new StringBuilder(); - sb.append("Rendering [").append(outputFile).append("]... "); Map model = new HashMap(); model.put("content", content); model.put("renderer", renderingEngine); try { - Writer out = createWriter(outputFile); - renderingEngine.renderDocument(model, findTemplateName(docType), out); - out.close(); - sb.append("done!"); - LOGGER.info(sb.toString()); + try (Writer out = createWriter(outputFile)) { + renderingEngine.renderDocument(model, findTemplateName(docType), out); + } + LOGGER.info("Rendering [{}]... done!", outputFile); } catch (Exception e) { - sb.append("failed!"); - LOGGER.error(sb.toString(), e); + LOGGER.error("Rendering [{}]... failed!", outputFile, e); throw new Exception("Failed to render file " + outputFile.getAbsolutePath() + ". Cause: " + e.getMessage(), e); } } @@ -228,18 +224,13 @@ private Writer createWriter(File file) throws IOException { private void render(RenderingConfig renderConfig) throws Exception { File outputFile = renderConfig.getPath(); - StringBuilder sb = new StringBuilder(); - sb.append("Rendering ").append(renderConfig.getName()).append(" [").append(outputFile).append("]..."); - try { - Writer out = createWriter(outputFile); - renderingEngine.renderDocument(renderConfig.getModel(), renderConfig.getTemplate(), out); - out.close(); - sb.append("done!"); - LOGGER.info(sb.toString()); + try (Writer out = createWriter(outputFile)) { + renderingEngine.renderDocument(renderConfig.getModel(), renderConfig.getTemplate(), out); + } + LOGGER.info("Rendering {} [{}]... done!", renderConfig.getName(), outputFile); } catch (Exception e) { - sb.append("failed!"); - LOGGER.error(sb.toString(), e); + LOGGER.error("Rendering {} [{}]... failed!", renderConfig.getName(), outputFile, e); throw new Exception("Failed to render " + renderConfig.getName(), e); } } diff --git a/src/main/java/org/jbake/launcher/CustomFSChangeListener.java b/src/main/java/org/jbake/launcher/CustomFSChangeListener.java index 904151728..9ee1b2099 100644 --- a/src/main/java/org/jbake/launcher/CustomFSChangeListener.java +++ b/src/main/java/org/jbake/launcher/CustomFSChangeListener.java @@ -21,19 +21,19 @@ public CustomFSChangeListener(LaunchOptions res, CompositeConfiguration config) @Override public void fileCreated(FileChangeEvent event) throws Exception { - LOGGER.info("File created event detected: " + event.getFile().getURL()); + LOGGER.info("File created event detected: {}", event.getFile().getURL()); exec(); } @Override public void fileDeleted(FileChangeEvent event) throws Exception { - LOGGER.info("File deleted event detected: " + event.getFile().getURL()); + LOGGER.info("File deleted event detected: {}", event.getFile().getURL()); exec(); } @Override public void fileChanged(FileChangeEvent event) throws Exception { - LOGGER.info("File changed event detected: " + event.getFile().getURL()); + LOGGER.info("File changed event detected: {}", event.getFile().getURL()); exec(); } diff --git a/src/main/java/org/jbake/parser/Engines.java b/src/main/java/org/jbake/parser/Engines.java index febf77f0d..dc9c2329a 100644 --- a/src/main/java/org/jbake/parser/Engines.java +++ b/src/main/java/org/jbake/parser/Engines.java @@ -132,7 +132,7 @@ private static void registerEngine(String className, String... extensions) { register(extension, engine); } if (engine instanceof ErrorEngine) { - LOGGER.warn("Unable to load a suitable rendering engine for extensions {}", Arrays.toString(extensions)); + LOGGER.warn("Unable to load a suitable rendering engine for extensions {}", (Object) extensions); } } } diff --git a/src/main/java/org/jbake/parser/MarkupEngine.java b/src/main/java/org/jbake/parser/MarkupEngine.java index 803ca4023..c516c3826 100644 --- a/src/main/java/org/jbake/parser/MarkupEngine.java +++ b/src/main/java/org/jbake/parser/MarkupEngine.java @@ -68,7 +68,7 @@ public Map parse(Configuration config, File file, String content is = new FileInputStream(file); fileContents = IOUtils.readLines(is, config.getString(Keys.RENDER_ENCODING)); } catch (IOException e) { - LOGGER.error("Error while opening file {}: {}", file, e); + LOGGER.error("Error while opening file {}", file, e); return null; } finally { @@ -125,7 +125,7 @@ public Map parse(Configuration config, File file, String content if (validate(context)) { processBody(context); } else { - LOGGER.error("Incomplete source file ({}) for markup engine:", file, getClass().getSimpleName()); + LOGGER.error("Incomplete source file ({}) for markup engine: {}", file, getClass().getSimpleName()); return null; } diff --git a/src/main/java/org/jbake/template/ModelExtractors.java b/src/main/java/org/jbake/template/ModelExtractors.java index ee417d0a3..599a2b466 100644 --- a/src/main/java/org/jbake/template/ModelExtractors.java +++ b/src/main/java/org/jbake/template/ModelExtractors.java @@ -150,7 +150,7 @@ public Set keySet() { public void registerExtractorsForCustomTypes(String docType) { String pluralizedDoctype = DocumentTypeUtils.pluralize(docType); if (!containsKey(pluralizedDoctype)) { - LOGGER.info("register new extractors for document type: " + docType); + LOGGER.info("register new extractors for document type: {}", docType); registerEngine(pluralizedDoctype, new TypedDocumentsExtractor()); registerEngine("published_" + pluralizedDoctype, new PublishedCustomExtractor(docType)); }