|
7 | 7 |
|
8 | 8 | prelude |
9 | 9 | public import Lean.PostprocessTraces.Basic |
| 10 | +public import Lean.PostprocessTraces.PostprocessTracesCommand |
| 11 | +public import Lean.PostprocessTraces.StoredTraces |
| 12 | +public import Lean.PostprocessTraces.Postprocessors |
| 13 | + |
| 14 | +/-! |
| 15 | +# Experimental: Trace Postprocessors |
| 16 | +
|
| 17 | +Trace messages of complex elaboration tasks can be large, and finding the relevant part in |
| 18 | +the editor requires a lot of clicking and searching. This module provides trace postprocessors: |
| 19 | +functions that transform the trace of a command before it is reported, e.g. by filtering out |
| 20 | +irrelevant subtrees, hoisting the interesting ones, or pre-expanding the paths to matches. |
| 21 | +
|
| 22 | +A trace postprocessor (`Lean.PostprocessTraces.TracePostprocessor`) receives the array of trace |
| 23 | +trees of one trace message and returns the transformed trees. The `Lean.PostprocessTraces` namespace |
| 24 | +provides a small set of operations (`filterSubtrees`, `hoist`, `exposeSubtrees`, `countNodes`, |
| 25 | +`selfTime`) that compose left-to-right with `>=>`. The selecting operations take a pattern |
| 26 | +(`Lean.PostprocessTraces.TracePattern`), a predicate on trace subtrees; built-in patterns select by |
| 27 | +trace class (`ofClass`), text (`containsString`), result (`succeeded`, `failed`, `errored`, |
| 28 | +`unsuccessful`), and time (`minTimeMs`, `minSelfTimeMs`). Users can define their own postprocessors |
| 29 | +and patterns as ordinary functions. |
| 30 | +
|
| 31 | +Entry points: |
| 32 | +- `postprocess_traces post in cmd` (see `Lean.PostprocessTraces.Command`) transforms the trace |
| 33 | + messages produced by `cmd` with `post`. |
| 34 | +- `store_traces_as t in cmd` (see `Lean.PostprocessTraces.StoredTraces`) stores the trace messages of |
| 35 | + `cmd` under the name `t`, so that slow commands do not have to be re-run while iterating on a |
| 36 | + postprocessor. |
| 37 | +
|
| 38 | +Traces are stored as `MessageData` (see `MessageData.trace`); `TraceTree` is a structured view of |
| 39 | +such messages that takes care of the context wrappers (`MessageData.withContext` etc.) around |
| 40 | +trace nodes. |
| 41 | +-/ |
0 commit comments