From dc0ac78a31de7a5081ad32ce0feb4c699cef8fec Mon Sep 17 00:00:00 2001 From: Zac Spitzer Date: Sat, 10 Apr 2021 17:25:31 +0200 Subject: [PATCH] enable debug parts and debugExecutionLog (#1271) * enable debugExecutionLog i.e. via CFCONFIG "executionLog": { "enabled": true ,"class": "debug" ,"arguments": "" ,"classArguments": "" } } --- .../main/java/lucee/runtime/config/ConfigWebFactory.java | 2 ++ core/src/main/java/lucee/runtime/debug/DebuggerImpl.java | 7 +++++-- .../java/lucee/runtime/engine/ConsoleExecutionLog.java | 2 +- 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/core/src/main/java/lucee/runtime/config/ConfigWebFactory.java b/core/src/main/java/lucee/runtime/config/ConfigWebFactory.java index d29f97ae72..58ba4c054c 100755 --- a/core/src/main/java/lucee/runtime/config/ConfigWebFactory.java +++ b/core/src/main/java/lucee/runtime/config/ConfigWebFactory.java @@ -113,6 +113,7 @@ import lucee.runtime.dump.TextDumpWriter; import lucee.runtime.engine.CFMLEngineImpl; import lucee.runtime.engine.ConsoleExecutionLog; +import lucee.runtime.engine.DebugExecutionLog; import lucee.runtime.engine.ExecutionLog; import lucee.runtime.engine.ExecutionLogFactory; import lucee.runtime.engine.InfoImpl; @@ -1909,6 +1910,7 @@ else if (!IOUtil.toString(exeLog, SystemUtil.getCharset()).equals(val)) { if (!StringUtil.isEmpty(strClass)) { try { if ("console".equalsIgnoreCase(strClass)) clazz = ConsoleExecutionLog.class; + else if ("debug".equalsIgnoreCase(strClass)) clazz = DebugExecutionLog.class; else { ClassDefinition cd = el != null ? getClassDefinition(el, "", config.getIdentification()) : null; diff --git a/core/src/main/java/lucee/runtime/debug/DebuggerImpl.java b/core/src/main/java/lucee/runtime/debug/DebuggerImpl.java index 9167ab8e48..3f1c484132 100644 --- a/core/src/main/java/lucee/runtime/debug/DebuggerImpl.java +++ b/core/src/main/java/lucee/runtime/debug/DebuggerImpl.java @@ -165,6 +165,7 @@ public DebugEntryTemplate getEntry(PageContext pc, PageSource source) { return getEntry(pc, source, null); } + // add pages entry @Override public DebugEntryTemplate getEntry(PageContext pc, PageSource source, String key) { lastEntry = System.currentTimeMillis(); @@ -184,6 +185,7 @@ public DebugEntryTemplate getEntry(PageContext pc, PageSource source, String key return de; } + // add page parts entry @Override public DebugEntryTemplatePart getEntry(PageContext pc, PageSource source, int startPos, int endPos) { String src = DebugEntryTemplatePartImpl.getSrc(source == null ? "" : source.getDisplayPath(), startPos, endPos); @@ -517,8 +519,6 @@ public Struct getDebuggingData(PageContext pc, boolean addAddionalInfo) throws D int qrySize = 0; Query qryPart = null; if (hasParts) { - qryPart = new QueryImpl(PAGE_PART_COLUMNS, qrySize, "query"); - debugging.setEL(PAGE_PARTS, qryPart); String slowestTemplate = arrPages.get(0).getPath(); List filteredPartEntries = new ArrayList(); java.util.Collection col = partEntries.values(); @@ -528,6 +528,9 @@ public Struct getDebuggingData(PageContext pc, boolean addAddionalInfo) throws D } qrySize = Math.min(filteredPartEntries.size(), MAX_PARTS); + qryPart = new QueryImpl(PAGE_PART_COLUMNS, qrySize, "query"); + debugging.setEL(PAGE_PARTS, qryPart); + int row = 0; Collections.sort(filteredPartEntries, DEBUG_ENTRY_TEMPLATE_PART_COMPARATOR); diff --git a/core/src/main/java/lucee/runtime/engine/ConsoleExecutionLog.java b/core/src/main/java/lucee/runtime/engine/ConsoleExecutionLog.java index d7a7c25c3f..ce6e563321 100644 --- a/core/src/main/java/lucee/runtime/engine/ConsoleExecutionLog.java +++ b/core/src/main/java/lucee/runtime/engine/ConsoleExecutionLog.java @@ -47,7 +47,7 @@ protected void _init(PageContext pc, Map arguments) { protected void _log(int startPos, int endPos, long startTime, long endTime) { long diff = endTime - startTime; - LogUtil.log(ThreadLocalPageContext.getConfig(pc), Log.LEVEL_INFO, Controler.class.getName(), + LogUtil.log(ThreadLocalPageContext.getConfig(pc), Log.LEVEL_TRACE, Controler.class.getName(), pc.getId() + ":" + pc.getCurrentPageSource().getDisplayPath() + ":" + positons(startPos, endPos) + " > " + timeLongToString(diff)); }