From 850bc6f80f315b5991d935bbd9e56aa0bf843885 Mon Sep 17 00:00:00 2001 From: Daniel <845765@qq.com> Date: Wed, 15 Nov 2023 11:22:08 +0800 Subject: [PATCH] =?UTF-8?q?:art:=20=E8=B0=83=E6=95=B4=20logging=20https://?= =?UTF-8?q?github.com/88250/symphony/pull/81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/org/b3log/symphony/util/Templates.java | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/src/main/java/org/b3log/symphony/util/Templates.java b/src/main/java/org/b3log/symphony/util/Templates.java index 7f7e7d506..fb29a98f0 100644 --- a/src/main/java/org/b3log/symphony/util/Templates.java +++ b/src/main/java/org/b3log/symphony/util/Templates.java @@ -17,10 +17,7 @@ */ package org.b3log.symphony.util; -import freemarker.template.Configuration; -import freemarker.template.Template; -import freemarker.template.TemplateExceptionHandler; -import freemarker.template.Version; +import freemarker.template.*; import org.apache.commons.lang3.StringUtils; import org.apache.logging.log4j.Level; import org.apache.logging.log4j.LogManager; @@ -32,7 +29,7 @@ * Templates utilities. * * @author Liang Ding - * @version 2.0.0.2, Jun 20, 2020 + * @version 2.0.0.3, Nov 15, 2023 * @since 1.3.0 */ public final class Templates { @@ -62,19 +59,17 @@ public final class Templates { // 开发时使用源码目录 path = StringUtils.replace(path, "/target/classes/", "/src/main/resources/"); path = StringUtils.replace(path, "/target/test-classes/", "/src/main/resources/"); - LOGGER.log(Level.DEBUG, "Adjusted resource path for development environment: " + path); // 添加调试信息 } if (StringUtils.contains(path, "/target/symphony/")) { // 开发时使用源码目录 path = StringUtils.replace(path, "/target/symphony/", "/src/main/resources/"); - LOGGER.log(Level.DEBUG, "Adjusted resource path for development environment: " + path); // 添加调试信息 } path += "skins"; TEMPLATE_CFG.setDirectoryForTemplateLoading(new File(path)); LOGGER.log(Level.INFO, "Loaded template from directory [" + path + "]"); } catch (final Exception e) { TEMPLATE_CFG.setClassForTemplateLoading(Templates.class, "/skins"); - LOGGER.log(Level.INFO, "Failed to load template from directory, loading from classpath", e); // 记录错误信息 + LOGGER.log(Level.INFO, "Loaded template from classpath"); } TEMPLATE_CFG.setTemplateExceptionHandler(TemplateExceptionHandler.RETHROW_HANDLER); TEMPLATE_CFG.setLogTemplateExceptions(false);