Follow up for trace pretty printing (#1227)

This commit is contained in:
Jen Basch
2025-10-08 09:36:42 -07:00
committed by GitHub
parent cf9d87373d
commit e230fcf1a9
29 changed files with 186 additions and 119 deletions

View File

@@ -23,6 +23,7 @@ import java.util.concurrent.TimeUnit;
import org.openjdk.jmh.annotations.*; import org.openjdk.jmh.annotations.*;
import org.openjdk.jmh.util.TempFile; import org.openjdk.jmh.util.TempFile;
import org.openjdk.jmh.util.TempFileManager; import org.openjdk.jmh.util.TempFileManager;
import org.pkl.core.evaluatorSettings.TraceMode;
import org.pkl.core.http.HttpClient; import org.pkl.core.http.HttpClient;
import org.pkl.core.module.ModuleKeyFactories; import org.pkl.core.module.ModuleKeyFactories;
import org.pkl.core.repl.ReplRequest; import org.pkl.core.repl.ReplRequest;
@@ -52,7 +53,7 @@ public class ListSort {
IoUtils.getCurrentWorkingDir(), IoUtils.getCurrentWorkingDir(),
StackFrameTransformers.defaultTransformer, StackFrameTransformers.defaultTransformer,
false, false,
null); TraceMode.COMPACT);
private static final List<Object> list = new ArrayList<>(100000); private static final List<Object> list = new ArrayList<>(100000);
static { static {

View File

@@ -15,6 +15,7 @@ import org.pkl.commons.test.FileTestUtils.rootProjectDir
import org.pkl.core.Loggers import org.pkl.core.Loggers
import org.pkl.core.SecurityManagers import org.pkl.core.SecurityManagers
import org.pkl.core.StackFrameTransformers import org.pkl.core.StackFrameTransformers
import org.pkl.core.evaluatorSettings.TraceMode
import org.pkl.core.module.ModuleKeyFactories import org.pkl.core.module.ModuleKeyFactories
import org.pkl.core.repl.ReplRequest import org.pkl.core.repl.ReplRequest
import org.pkl.core.repl.ReplResponse import org.pkl.core.repl.ReplResponse
@@ -97,7 +98,7 @@ class DocSnippetTestsEngine : HierarchicalTestEngine<DocSnippetTestsEngine.Execu
IoUtils.getCurrentWorkingDir(), IoUtils.getCurrentWorkingDir(),
StackFrameTransformers.defaultTransformer, StackFrameTransformers.defaultTransformer,
false, false,
null TraceMode.COMPACT,
) )
return ExecutionContext(replServer) return ExecutionContext(replServer)
} }

View File

@@ -19,6 +19,7 @@ import org.pkl.cli.repl.Repl
import org.pkl.commons.cli.CliCommand import org.pkl.commons.cli.CliCommand
import org.pkl.core.Loggers import org.pkl.core.Loggers
import org.pkl.core.SecurityManagers import org.pkl.core.SecurityManagers
import org.pkl.core.evaluatorSettings.TraceMode
import org.pkl.core.module.ModuleKeyFactories import org.pkl.core.module.ModuleKeyFactories
import org.pkl.core.module.ModulePathResolver import org.pkl.core.module.ModulePathResolver
import org.pkl.core.repl.ReplServer import org.pkl.core.repl.ReplServer
@@ -68,7 +69,7 @@ internal class CliRepl(private val options: CliEvaluatorOptions) : CliCommand(op
options.base.normalizedWorkingDir, options.base.normalizedWorkingDir,
stackFrameTransformer, stackFrameTransformer,
options.base.color?.hasColor() ?: false, options.base.color?.hasColor() ?: false,
options.base.traceMode, options.base.traceMode ?: TraceMode.COMPACT,
) )
Repl(options.base.normalizedWorkingDir, server).run() Repl(options.base.normalizedWorkingDir, server).run()
} }

View File

@@ -21,6 +21,7 @@ import org.pkl.commons.toPath
import org.pkl.core.Loggers import org.pkl.core.Loggers
import org.pkl.core.SecurityManagers import org.pkl.core.SecurityManagers
import org.pkl.core.StackFrameTransformers import org.pkl.core.StackFrameTransformers
import org.pkl.core.evaluatorSettings.TraceMode
import org.pkl.core.http.HttpClient import org.pkl.core.http.HttpClient
import org.pkl.core.module.ModuleKeyFactories import org.pkl.core.module.ModuleKeyFactories
import org.pkl.core.repl.ReplRequest import org.pkl.core.repl.ReplRequest
@@ -43,7 +44,7 @@ class ReplMessagesTest {
"/".toPath(), "/".toPath(),
StackFrameTransformers.defaultTransformer, StackFrameTransformers.defaultTransformer,
false, false,
null, TraceMode.COMPACT,
) )
@Test @Test

View File

@@ -295,16 +295,15 @@ class BaseOptions : OptionGroup() {
.multiple() .multiple()
.toMap() .toMap()
val traceMode: TraceMode by val traceMode: TraceMode? by
option( option(
names = arrayOf("--trace-mode"), names = arrayOf("--trace-mode"),
metavar = "when", metavar = "style",
help = help =
"Specifies how calls to trace() are formatted. Possible values of <when> are 'default', 'pretty' and 'hidden'.", "Specifies how calls to trace() are formatted. Possible values of <style> are 'compact' and 'pretty'.",
) )
.enum<TraceMode> { it.name.lowercase() } .enum<TraceMode> { it.name.lowercase() }
.single() .single()
.default(TraceMode.DEFAULT)
// hidden option used by native tests // hidden option used by native tests
private val testPort: Int by private val testPort: Int by

View File

@@ -57,7 +57,7 @@ public class Analyzer {
@Nullable Path moduleCacheDir, @Nullable Path moduleCacheDir,
@Nullable DeclaredDependencies projectDependencies, @Nullable DeclaredDependencies projectDependencies,
HttpClient httpClient, HttpClient httpClient,
@Nullable TraceMode traceMode) { TraceMode traceMode) {
this.transformer = transformer; this.transformer = transformer;
this.color = color; this.color = color;
this.securityManager = securityManager; this.securityManager = securityManager;

View File

@@ -68,7 +68,7 @@ public final class EvaluatorBuilder {
private @Nullable DeclaredDependencies dependencies; private @Nullable DeclaredDependencies dependencies;
private @Nullable TraceMode traceMode; private TraceMode traceMode = TraceMode.COMPACT;
private EvaluatorBuilder() {} private EvaluatorBuilder() {}

View File

@@ -82,7 +82,7 @@ public class EvaluatorImpl implements Evaluator {
@Nullable Path moduleCacheDir, @Nullable Path moduleCacheDir,
@Nullable DeclaredDependencies projectDependencies, @Nullable DeclaredDependencies projectDependencies,
@Nullable String outputFormat, @Nullable String outputFormat,
@Nullable TraceMode traceMode) { TraceMode traceMode) {
securityManager = manager; securityManager = manager;
frameTransformer = transformer; frameTransformer = transformer;

View File

@@ -1,5 +1,5 @@
/* /*
* Copyright © 2024 Apple Inc. and the Pkl project authors. All rights reserved. * Copyright © 2024-2025 Apple Inc. and the Pkl project authors. All rights reserved.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@@ -80,6 +80,13 @@ public final class Loggers {
} }
private static String formatMessage(String level, String message, StackFrame frame) { private static String formatMessage(String level, String message, StackFrame frame) {
return "pkl: " + level + ": " + message + " (" + frame.getModuleUri() + ')'; return "pkl: "
+ level
+ ": "
+ message
+ (message.endsWith("\n") ? "" : " ")
+ "("
+ frame.getModuleUri()
+ ')';
} }
} }

View File

@@ -18,8 +18,9 @@ package org.pkl.core.ast.expression.unary;
import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary; import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary;
import com.oracle.truffle.api.frame.VirtualFrame; import com.oracle.truffle.api.frame.VirtualFrame;
import com.oracle.truffle.api.source.SourceSection; import com.oracle.truffle.api.source.SourceSection;
import java.util.Arrays;
import java.util.stream.Collectors;
import org.pkl.core.ast.ExpressionNode; import org.pkl.core.ast.ExpressionNode;
import org.pkl.core.evaluatorSettings.TraceMode;
import org.pkl.core.runtime.*; import org.pkl.core.runtime.*;
public final class TraceNode extends ExpressionNode { public final class TraceNode extends ExpressionNode {
@@ -27,9 +28,8 @@ public final class TraceNode extends ExpressionNode {
private static final int MAX_RENDERER_LENGTH = 1000000; private static final int MAX_RENDERER_LENGTH = 1000000;
private final VmValueRenderer singleLineRenderer = private final VmValueRenderer compactRenderer = VmValueRenderer.singleLine(MAX_RENDERER_LENGTH);
VmValueRenderer.singleLine(MAX_RENDERER_LENGTH); private final VmValueRenderer prettyRenderer = VmValueRenderer.multiLine(Integer.MAX_VALUE);
private final VmValueRenderer multiLineRenderer = VmValueRenderer.multiLine(MAX_RENDERER_LENGTH);
public TraceNode(SourceSection sourceSection, ExpressionNode valueNode) { public TraceNode(SourceSection sourceSection, ExpressionNode valueNode) {
super(sourceSection); super(sourceSection);
@@ -45,29 +45,23 @@ public final class TraceNode extends ExpressionNode {
@TruffleBoundary @TruffleBoundary
private void doTrace(Object value, VmContext context) { private void doTrace(Object value, VmContext context) {
// If traces are disabled, returns early. VmValue.force(value, true);
if (context.getTraceMode() == TraceMode.HIDDEN) {
return;
}
if (value instanceof VmObjectLike objectLike) {
try {
objectLike.force(true, true);
} catch (VmException ignored) {
}
}
var sourceSection = valueNode.getSourceSection(); var sourceSection = valueNode.getSourceSection();
String renderedValue; var lhs = sourceSection.isAvailable() ? sourceSection.getCharacters().toString() : "<value>";
if (context.getTraceMode() == TraceMode.PRETTY) {
renderedValue = multiLineRenderer.render(value);
} else {
renderedValue = singleLineRenderer.render(value);
}
var message = var message =
(sourceSection.isAvailable() ? sourceSection.getCharacters() : "<value") switch (context.getTraceMode()) {
+ " = " case COMPACT -> lhs + " = " + compactRenderer.render(value);
+ renderedValue; case PRETTY -> {
var rhs = prettyRenderer.render(value);
yield (lhs.contains("\n") ? "\n" + addIndent(lhs, " ") + "\n=" : lhs + " =")
+ (rhs.contains("\n") ? "\n" + addIndent(rhs, " ") : " " + rhs)
+ "\n";
}
};
context.getLogger().trace(message, VmUtils.createStackFrame(sourceSection, null)); context.getLogger().trace(message, VmUtils.createStackFrame(sourceSection, null));
} }
private static String addIndent(String s, String indent) {
return Arrays.stream(s.split("\n")).map((it) -> indent + it).collect(Collectors.joining("\n"));
}
} }

View File

@@ -17,10 +17,8 @@ package org.pkl.core.evaluatorSettings;
/** Dictates the rendering of calls to the trace() method within Pkl. */ /** Dictates the rendering of calls to the trace() method within Pkl. */
public enum TraceMode { public enum TraceMode {
/** All trace() calls will not be emitted to stderr. */
HIDDEN,
/** All structures passed to trace() will be emitted on a single line. */ /** All structures passed to trace() will be emitted on a single line. */
DEFAULT, COMPACT,
/** All structures passed to trace() will be indented and emitted across multiple lines. */ /** All structures passed to trace() will be indented and emitted across multiple lines. */
PRETTY PRETTY
} }

View File

@@ -84,7 +84,7 @@ public class ReplServer implements AutoCloseable {
Path workingDir, Path workingDir,
StackFrameTransformer frameTransformer, StackFrameTransformer frameTransformer,
boolean color, boolean color,
@Nullable TraceMode traceMode) { TraceMode traceMode) {
this.workingDir = workingDir; this.workingDir = workingDir;
this.securityManager = securityManager; this.securityManager = securityManager;

View File

@@ -22,6 +22,7 @@ import java.util.Map;
import org.pkl.core.Loggers; import org.pkl.core.Loggers;
import org.pkl.core.SecurityManagers; import org.pkl.core.SecurityManagers;
import org.pkl.core.StackFrameTransformers; import org.pkl.core.StackFrameTransformers;
import org.pkl.core.evaluatorSettings.TraceMode;
import org.pkl.core.http.HttpClient; import org.pkl.core.http.HttpClient;
import org.pkl.core.module.ModuleKeyFactories; import org.pkl.core.module.ModuleKeyFactories;
import org.pkl.core.module.ModuleKeys; import org.pkl.core.module.ModuleKeys;
@@ -50,7 +51,7 @@ public abstract class StdLibModule {
null, null,
null, null,
null, null,
null)); TraceMode.COMPACT));
var language = VmLanguage.get(null); var language = VmLanguage.get(null);
var moduleKey = ModuleKeys.standardLibrary(uri); var moduleKey = ModuleKeys.standardLibrary(uri);
var source = VmUtils.loadSource((ResolvedModuleKey) moduleKey); var source = VmUtils.loadSource((ResolvedModuleKey) moduleKey);

View File

@@ -66,7 +66,7 @@ public final class VmContext {
@Nullable String outputFormat, @Nullable String outputFormat,
@Nullable PackageResolver packageResolver, @Nullable PackageResolver packageResolver,
@Nullable ProjectDependenciesManager projectDependenciesManager, @Nullable ProjectDependenciesManager projectDependenciesManager,
@Nullable TraceMode traceMode) { TraceMode traceMode) {
this.frameTransformer = frameTransformer; this.frameTransformer = frameTransformer;
this.securityManager = securityManager; this.securityManager = securityManager;
@@ -148,7 +148,7 @@ public final class VmContext {
return holder.projectDependenciesManager; return holder.projectDependenciesManager;
} }
public @Nullable TraceMode getTraceMode() { public TraceMode getTraceMode() {
return holder.traceMode; return holder.traceMode;
} }
} }

View File

@@ -1,5 +1,5 @@
amends "pkl:Project" amends "pkl:Project"
evaluatorSettings { evaluatorSettings {
traceMode = "default" traceMode = "compact"
} }

View File

@@ -1,5 +0,0 @@
amends "pkl:Project"
evaluatorSettings {
traceMode = "hidden"
}

View File

@@ -1,18 +0,0 @@
amends ".../snippetTest.pkl"
examples {
["traceMode = 'hidden' results in no trace output"] {
trace(new {
["Parrot"] {
name = "Parrot"
age = 1234
bucketSettings = new {
kicked = true
["fjordConfig"] = new {
isPining = true
}
}
}
})
}
}

View File

@@ -1,7 +1,51 @@
amends ".../snippetTest.pkl" amends ".../snippetTest.pkl"
examples { examples {
["traceMode = 'pretty' results in indented, multi-line output"] { ["single-line lhs, single-line rhs"] {
let (val = new Dynamic {
["Parrot"] {
name = "Parrot"
age = 1234
bucketSettings = new {
kicked = true
["fjordConfig"] = new {
isPining = true
}
}
}
})
trace(val["Parrot"].name)
}
["single-line lhs, multi-line rhs"] {
let (val = new Dynamic {
["Parrot"] {
name = "Parrot"
age = 1234
bucketSettings = new {
kicked = true
["fjordConfig"] = new {
isPining = true
}
}
}
})
trace(val)
}
["multi-line lhs, single-line rhs"] {
trace((new Dynamic {
["Parrot"] {
name = "Parrot"
age = 1234
bucketSettings = new {
kicked = true
["fjordConfig"] = new {
isPining = true
}
}
}
})["Parrot"].name)
}
["multi-line lhs, multi-line rhs"] {
trace(new { trace(new {
["Parrot"] { ["Parrot"] {
name = "Parrot" name = "Parrot"

View File

@@ -25,4 +25,4 @@ pkl: TRACE: new {
} }
} }
} }
} = new Dynamic { ["Parrot"] { name = "Parrot"; age = 1234; bucketSettings { kicked = true; ["fjordConfig"] { isPining = true } } } } (file:///$snippetsDir/input/projects/defaultTraceMode/defaultTraceMode.pkl) } = new Dynamic { ["Parrot"] { name = "Parrot"; age = 1234; bucketSettings { kicked = true; ["fjordConfig"] { isPining = true } } } } (file:///$snippetsDir/input/projects/compactTraceMode/compactTraceMode.pkl)

View File

@@ -1,16 +0,0 @@
examples {
["traceMode = 'hidden' results in no trace output"] {
new {
["Parrot"] {
name = "Parrot"
age = 1234
bucketSettings {
kicked = true
["fjordConfig"] {
isPining = true
}
}
}
}
}
}

View File

@@ -1,5 +1,25 @@
examples { examples {
["traceMode = 'pretty' results in indented, multi-line output"] { ["single-line lhs, single-line rhs"] {
"Parrot"
}
["single-line lhs, multi-line rhs"] {
new {
["Parrot"] {
name = "Parrot"
age = 1234
bucketSettings {
kicked = true
["fjordConfig"] {
isPining = true
}
}
}
}
}
["multi-line lhs, single-line rhs"] {
"Parrot"
}
["multi-line lhs, multi-line rhs"] {
new { new {
["Parrot"] { ["Parrot"] {
name = "Parrot" name = "Parrot"
@@ -14,26 +34,61 @@ examples {
} }
} }
} }
pkl: TRACE: new { pkl: TRACE: val["Parrot"].name = "Parrot"
["Parrot"] { (file:///$snippetsDir/input/projects/prettyTraceMode/prettyTraceMode.pkl)
name = "Parrot" pkl: TRACE: val =
age = 1234 new Dynamic {
bucketSettings = new { ["Parrot"] {
kicked = true name = "Parrot"
["fjordConfig"] = new { age = 1234
isPining = true bucketSettings {
} kicked = true
["fjordConfig"] {
isPining = true
} }
} }
} = new Dynamic {
["Parrot"] {
name = "Parrot"
age = 1234
bucketSettings {
kicked = true
["fjordConfig"] {
isPining = true
}
} }
} }
} (file:///$snippetsDir/input/projects/prettyTraceMode/prettyTraceMode.pkl) (file:///$snippetsDir/input/projects/prettyTraceMode/prettyTraceMode.pkl)
pkl: TRACE:
(new Dynamic {
["Parrot"] {
name = "Parrot"
age = 1234
bucketSettings = new {
kicked = true
["fjordConfig"] = new {
isPining = true
}
}
}
})["Parrot"].name
= "Parrot"
(file:///$snippetsDir/input/projects/prettyTraceMode/prettyTraceMode.pkl)
pkl: TRACE:
new {
["Parrot"] {
name = "Parrot"
age = 1234
bucketSettings = new {
kicked = true
["fjordConfig"] = new {
isPining = true
}
}
}
}
=
new Dynamic {
["Parrot"] {
name = "Parrot"
age = 1234
bucketSettings {
kicked = true
["fjordConfig"] {
isPining = true
}
}
}
}
(file:///$snippetsDir/input/projects/prettyTraceMode/prettyTraceMode.pkl)

View File

@@ -23,6 +23,7 @@ import org.junit.jupiter.api.Test
import org.junit.jupiter.api.io.TempDir import org.junit.jupiter.api.io.TempDir
import org.pkl.commons.test.PackageServer import org.pkl.commons.test.PackageServer
import org.pkl.commons.writeString import org.pkl.commons.writeString
import org.pkl.core.evaluatorSettings.TraceMode
import org.pkl.core.http.HttpClient import org.pkl.core.http.HttpClient
import org.pkl.core.module.ModuleKeyFactories import org.pkl.core.module.ModuleKeyFactories
import org.pkl.core.project.Project import org.pkl.core.project.Project
@@ -37,7 +38,7 @@ class AnalyzerTest {
null, null,
null, null,
HttpClient.dummyClient(), HttpClient.dummyClient(),
null, TraceMode.COMPACT,
) )
@Test @Test
@@ -116,7 +117,7 @@ class AnalyzerTest {
tempDir.resolve("packages"), tempDir.resolve("packages"),
null, null,
HttpClient.dummyClient(), HttpClient.dummyClient(),
null, TraceMode.COMPACT,
) )
PackageServer.populateCacheDir(tempDir.resolve("packages")) PackageServer.populateCacheDir(tempDir.resolve("packages"))
val file1 = val file1 =
@@ -192,7 +193,7 @@ class AnalyzerTest {
tempDir.resolve("packages"), tempDir.resolve("packages"),
project.dependencies, project.dependencies,
HttpClient.dummyClient(), HttpClient.dummyClient(),
null, TraceMode.COMPACT,
) )
val file1 = val file1 =
tempDir tempDir
@@ -305,7 +306,7 @@ class AnalyzerTest {
tempDir.resolve("packages"), tempDir.resolve("packages"),
project.dependencies, project.dependencies,
HttpClient.dummyClient(), HttpClient.dummyClient(),
null, TraceMode.COMPACT,
) )
val result = analyzer.importGraph(mainPkl.toUri()) val result = analyzer.importGraph(mainPkl.toUri())
val birdUri = URI("projectpackage://localhost:0/birds@1.0.0#/bird.pkl") val birdUri = URI("projectpackage://localhost:0/birds@1.0.0#/bird.pkl")

View File

@@ -18,6 +18,7 @@ package org.pkl.core
import org.assertj.core.api.Assertions.assertThat import org.assertj.core.api.Assertions.assertThat
import org.junit.jupiter.api.Test import org.junit.jupiter.api.Test
import org.pkl.commons.toPath import org.pkl.commons.toPath
import org.pkl.core.evaluatorSettings.TraceMode
import org.pkl.core.http.HttpClient import org.pkl.core.http.HttpClient
import org.pkl.core.module.ModuleKeyFactories import org.pkl.core.module.ModuleKeyFactories
import org.pkl.core.repl.ReplRequest import org.pkl.core.repl.ReplRequest
@@ -45,7 +46,7 @@ class ReplServerTest {
"/".toPath(), "/".toPath(),
StackFrameTransformers.defaultTransformer, StackFrameTransformers.defaultTransformer,
false, false,
null, TraceMode.COMPACT,
) )
@Test @Test

View File

@@ -40,7 +40,7 @@ internal class BinaryEvaluator(
moduleCacheDir: Path?, moduleCacheDir: Path?,
declaredDependencies: DeclaredDependencies?, declaredDependencies: DeclaredDependencies?,
outputFormat: String?, outputFormat: String?,
traceMode: TraceMode?, traceMode: TraceMode,
) : ) :
EvaluatorImpl( EvaluatorImpl(
transformer, transformer,

View File

@@ -25,6 +25,7 @@ import java.util.regex.Pattern
import kotlin.random.Random import kotlin.random.Random
import org.pkl.core.* import org.pkl.core.*
import org.pkl.core.evaluatorSettings.PklEvaluatorSettings import org.pkl.core.evaluatorSettings.PklEvaluatorSettings
import org.pkl.core.evaluatorSettings.TraceMode
import org.pkl.core.externalreader.ExternalReaderProcess import org.pkl.core.externalreader.ExternalReaderProcess
import org.pkl.core.externalreader.ExternalResourceResolver import org.pkl.core.externalreader.ExternalResourceResolver
import org.pkl.core.externalreader.ModuleReaderSpec import org.pkl.core.externalreader.ModuleReaderSpec
@@ -227,7 +228,7 @@ class Server(private val transport: MessageTransport) : AutoCloseable {
cacheDir, cacheDir,
dependencies, dependencies,
message.outputFormat, message.outputFormat,
message.traceMode, message.traceMode ?: TraceMode.COMPACT,
) )
} catch (e: IllegalArgumentException) { } catch (e: IllegalArgumentException) {
throw ProtocolException(e.message ?: "Failed to create an evalutor. $e", e) throw ProtocolException(e.message ?: "Failed to create an evalutor. $e", e)

View File

@@ -21,6 +21,7 @@ import kotlin.reflect.KClass
import org.junit.platform.commons.annotation.Testable import org.junit.platform.commons.annotation.Testable
import org.pkl.commons.test.InputOutputTestEngine import org.pkl.commons.test.InputOutputTestEngine
import org.pkl.core.* import org.pkl.core.*
import org.pkl.core.evaluatorSettings.TraceMode
import org.pkl.core.http.HttpClient import org.pkl.core.http.HttpClient
import org.pkl.core.module.ModuleKeyFactories import org.pkl.core.module.ModuleKeyFactories
@@ -56,7 +57,7 @@ class BinaryEvaluatorSnippetTestEngine : InputOutputTestEngine() {
null, null,
null, null,
null, null,
null, TraceMode.COMPACT,
) )
private fun String.stripFilePaths() = private fun String.stripFilePaths() =

View File

@@ -21,6 +21,7 @@ import org.assertj.core.api.Assertions.assertThat
import org.junit.jupiter.api.Test import org.junit.jupiter.api.Test
import org.junit.jupiter.api.assertThrows import org.junit.jupiter.api.assertThrows
import org.pkl.core.* import org.pkl.core.*
import org.pkl.core.evaluatorSettings.TraceMode
import org.pkl.core.http.HttpClient import org.pkl.core.http.HttpClient
import org.pkl.core.module.ModuleKeyFactories import org.pkl.core.module.ModuleKeyFactories
import org.pkl.core.resource.ResourceReaders import org.pkl.core.resource.ResourceReaders
@@ -45,7 +46,7 @@ class BinaryEvaluatorTest {
null, null,
null, null,
null, null,
null, TraceMode.COMPACT,
) )
private fun evaluate(text: String, expression: String?) = private fun evaluate(text: String, expression: String?) =

View File

@@ -113,11 +113,10 @@ externalResourceReaders: Mapping<String, ExternalReader>?
/// ///
/// Possible values: /// Possible values:
/// ///
/// - `"hidden"`: All trace() calls will not be emitted to stderr. /// - `"compact"`: All structures passed to trace() will be emitted on a single line.
/// - `"default"`: All structures passed to trace() will be emitted on a single line.
/// - `"pretty"`: All structures passed to trace() will be indented and emitted across multiple lines. /// - `"pretty"`: All structures passed to trace() will be indented and emitted across multiple lines.
@Since { version = "0.30.0" } @Since { version = "0.30.0" }
traceMode: ("hidden"|"default"|"pretty")? traceMode: ("compact"|"pretty")?
const local hostnameRegex = Regex(#"https?://([^/?#]*)"#) const local hostnameRegex = Regex(#"https?://([^/?#]*)"#)