From 211fdf5389c33c49f5325ba4c5160dc9ca8565b0 Mon Sep 17 00:00:00 2001 From: michaeloffner Date: Fri, 22 Nov 2024 17:42:43 +0100 Subject: [PATCH] partly revert log changes and load function and tag settings on demand --- .../java/lucee/commons/io/log/LogUtil.java | 19 ++--- .../runtime/config/ConfigFactoryImpl.java | 70 +++++++++++-------- .../java/lucee/runtime/config/ConfigImpl.java | 45 +++++++++++- .../main/java/lucee/runtime/tag/Admin.java | 1 + .../main/java/lucee/runtime/tag/TagUtil.java | 4 +- loader/build.xml | 2 +- loader/pom.xml | 2 +- 7 files changed, 96 insertions(+), 47 deletions(-) diff --git a/core/src/main/java/lucee/commons/io/log/LogUtil.java b/core/src/main/java/lucee/commons/io/log/LogUtil.java index 834d3bbb75..ddd892f1b9 100644 --- a/core/src/main/java/lucee/commons/io/log/LogUtil.java +++ b/core/src/main/java/lucee/commons/io/log/LogUtil.java @@ -18,6 +18,7 @@ **/ package lucee.commons.io.log; +import java.io.File; import java.util.Date; import lucee.aprint; @@ -29,12 +30,11 @@ import lucee.commons.lang.ExceptionUtil; import lucee.commons.lang.StringUtil; import lucee.commons.lang.SystemOut; +import lucee.loader.engine.CFMLEngineFactory; import lucee.runtime.PageContext; import lucee.runtime.PageContextImpl; import lucee.runtime.PageSource; import lucee.runtime.config.Config; -import lucee.runtime.config.ConfigPro; -import lucee.runtime.config.ConfigServerImpl; import lucee.runtime.config.ConfigUtil; import lucee.runtime.config.ConfigWeb; import lucee.runtime.engine.ThreadLocalPageContext; @@ -208,11 +208,6 @@ public static void log(Config config, int level, String logName, String type, St } - public static void log(ConfigPro cw, Log log, String type, Exception e) { - if (log != null) log.error(type, e); - else log(cw, type, e); - } - public static void log(PageContext pc, int level, String logName, String type, String msg) { Log log = ThreadLocalPageContext.getLog(pc, logName); if (log != null) log.log(level, type, msg); @@ -222,15 +217,15 @@ public static void log(PageContext pc, int level, String logName, String type, S } public static void logGlobal(Config config, int level, String type, String msg) { - ConfigServerImpl cs = ConfigUtil.getConfigServerImpl(config); try { + CFMLEngineFactory factory = ConfigUtil.getCFMLEngineFactory(config); Resource log; boolean check = false; if (level > Log.LEVEL_DEBUG) { if (ERR == null) { - synchronized (cs) { + synchronized (factory) { if (ERR == null) { - ERR = cs.getConfigDir().getRealResource("logs/err.log"); + ERR = ResourceUtil.toResource(new File(factory.getResourceRoot(), "context/logs/err.log")); check = true; } } @@ -239,9 +234,9 @@ public static void logGlobal(Config config, int level, String type, String msg) } else { if (OUT == null) { - synchronized (cs) { + synchronized (factory) { if (OUT == null) { - OUT = cs.getConfigDir().getRealResource("logs/out.log"); + OUT = ResourceUtil.toResource(new File(factory.getResourceRoot(), "context/logs/out.log")); check = true; } } diff --git a/core/src/main/java/lucee/runtime/config/ConfigFactoryImpl.java b/core/src/main/java/lucee/runtime/config/ConfigFactoryImpl.java index 996e05de79..6d8d2c300d 100644 --- a/core/src/main/java/lucee/runtime/config/ConfigFactoryImpl.java +++ b/core/src/main/java/lucee/runtime/config/ConfigFactoryImpl.java @@ -279,10 +279,9 @@ public static ConfigServerImpl newInstanceServer(CFMLEngineImpl engine, Map 0; if (!hasConfigNew) { - LogUtil.logGlobal(ThreadLocalPageContext.getConfig(), Log.LEVEL_INFO, ConfigFactoryImpl.class.getName(), - "has no json server context config [" + configFileNew + "]"); + LogUtil.logGlobal(null, Log.LEVEL_INFO, ConfigFactoryImpl.class.getName(), "has no json server context config [" + configFileNew + "]"); hasConfigOld = configFileOld.exists() && configFileOld.length() > 0; - LogUtil.logGlobal(ThreadLocalPageContext.getConfig(), Log.LEVEL_INFO, ConfigFactoryImpl.class.getName(), + LogUtil.logGlobal(null, Log.LEVEL_INFO, ConfigFactoryImpl.class.getName(), "has " + (hasConfigOld ? "" : "no ") + "xml server context config [" + configFileOld + "]"); } ConfigServerImpl config = existing != null ? existing : new ConfigServerImpl(engine, initContextes, contextes, configDir, configFileNew, ui, essentialOnly, doNew); @@ -290,7 +289,7 @@ public static ConfigServerImpl newInstanceServer(CFMLEngineImpl engine, Map - + diff --git a/loader/pom.xml b/loader/pom.xml index b7acc2e15c..e1e65ac1cc 100644 --- a/loader/pom.xml +++ b/loader/pom.xml @@ -3,7 +3,7 @@ org.lucee lucee - 7.0.0.60-SNAPSHOT + 7.0.0.61-SNAPSHOT jar Lucee Loader Build