ActionLogBuilder

class ActionLogBuilder(val truncation: ActionLogTruncation, val json: Json)

DSL for building a stage action log. Obtained via StageScope.logAction.

  • Primitive overloads (put for Int, Long, Double, Boolean) emit JSON primitives directly.

  • put for String emits a JSON string; any truncation is applied globally in build.

  • Generic put with a @Serializable type encodes the value as a proper JSON element (array, object, …) using the json instance provided to StageScope.logActionnever wrapped as a string.

After all put calls, build applies ActionLogTruncation recursively to the entire JSON tree, so strings nested inside serialized objects or arrays are truncated by the same rule.

Constructors

Link copied to clipboard
constructor(truncation: ActionLogTruncation, json: Json)

Properties

Link copied to clipboard
val json: Json

JSON instance used to serialize values passed to the generic put.

Link copied to clipboard
val properties: MutableMap<String, JsonElement>

The accumulated log entries, keyed by name; mutated by the put calls.

Link copied to clipboard

Truncation applied to all string values when build is called.

Functions

Link copied to clipboard
fun build(): JsonObject

Assembles the accumulated properties into a JsonObject and applies truncation recursively to every string in the tree.

Link copied to clipboard
inline fun <T> put(key: String, value: T)

Serializes value as a proper JSON element (object, array, …) using this builder's json.

fun put(key: String, value: Boolean)

Records value under key as a JSON boolean.

fun put(key: String, value: Double)
fun put(key: String, value: Int)
fun put(key: String, value: Long)

Records value under key as a JSON number.

fun put(key: String, value: String)

Records value under key as a JSON string (subject to truncation in build).

Link copied to clipboard
inline fun <T> putIfNonEmpty(key: String, list: List<T>)

Adds list under key only when it is non-empty.