Explainer

class Explainer @JvmOverloads constructor(val verbosity: Explainer.Loglevel = Loglevel.INFO, val name: String = UUID.randomUUID().toString())

A diagnostic recorder for a single search run.

An instance collects why a search reached its result: which recipes became candidates, which check rejected a recipe, and which predicate failed. Pass one to io.github.sakaki_aruka.customcrafter.search.Search.search (or its async / partial counterparts) and read the collected lines back with getLogs or getStringList.

Lines are recorded only when their level is not more verbose than verbosity: Loglevel.WARN alone keeps errors, Loglevel.INFO adds what happened, and Loglevel.DEBUG adds the concrete values behind each decision.

This class is safe to share across threads. io.github.sakaki_aruka.customcrafter.search.Search.asyncSearch evaluates candidate recipes in parallel and writes to one instance from every worker, so lines from different recipes interleave. Every line carries the recipe it belongs to, and the recorded order is a faithful trace of the actual execution order.

Since

5.3.0

Parameters

verbosity

The most verbose level to keep. (default = Loglevel.INFO)

name

Label for this instance. Only used to tell instances apart. (default = a random UUID)

Constructors

Link copied to clipboard
constructor(verbosity: Explainer.Loglevel = Loglevel.INFO, name: String = UUID.randomUUID().toString())

Types

Link copied to clipboard
class Log(val level: Explainer.Loglevel, val line: String)

A single recorded line.

Link copied to clipboard

Severity of a recorded line.

Properties

Link copied to clipboard
Link copied to clipboard

Functions

Link copied to clipboard

Returns every recorded line in the order it was written.

Link copied to clipboard
fun getStringList(vararg targetLevels: Explainer.Loglevel): List<String>

Returns recorded lines rendered as "[LEVEL] message", keeping only targetLevels.

Link copied to clipboard
open override fun toString(): String
Link copied to clipboard

Records a line when level is not more verbose than verbosity.