You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
- Rename -delta-buffer to -match-buffer
- Rename -readjson to -read-json
- Rename -jsontemplate to -match-template
- Rename -start to -regex / -match-regex
- Rename -timeformat to -time-format
- Rename .JSONText to .MatchText
- Replace .StartText, .StartObject by .Start
- Literals (no "{{") given to -match / -match-template are automatically surrounded by {{}}
Additions:
- Add JSON stream parsing (one-object-per-line format no longer required)
- Add -match-condition
- Add -time-zone
- Add -scale-{sqr,cube,sqrt,cubert}
- Add Text and TimeColor preset templates
Internal:
- Refactor main to avoid duplicating logic between JSON/line input
The [constant names from pkg/time](https://golang.org/pkg/time/#pkg-constants) as well as regular go time layouts are admissible values for `-timeformat`:
110
+
The [constant names from pkg/time](https://golang.org/pkg/time/#pkg-constants) as well as regular go time layouts are admissible values for `-time-format`:
@@ -149,6 +176,11 @@ The color scale can be set using the parameters `-scale`, `-scale-fast`, and `-
149
176
- The `-scale` parameter defines the colors used in the scale.
150
177
- The `-scale-fast` and `-scale-slow` parameters define the boundaries of the scale: durations shorter than the value of `-scale-fast` are mapped to the leftmost color, durations longer than the value of `-scale-slow` are mapped to the rightmost color.
151
178
179
+
The scale is linear by default, but can be transformed:
180
+
181
+
-`-scale-sqr`, `-scale-sqrt` yields a quadratic (root) scale
182
+
-`-scale-cube`, `-scale-cubert` yields a cubic (root) scale
183
+
152
184
There are several pre-defined color scales:
153
185
154
186
| Name | Scale |
@@ -165,33 +197,44 @@ There are several pre-defined color scales:
165
197
166
198
You can also provide your own color scale using the same syntax as the pre-defined ones.
167
199
168
-
### Stopwatch regex
169
-
170
-
Sometimes you need to measure the duration between certain *tokens* in the input.
200
+
### JSON input
171
201
172
-
To help with this, `tj`can match each line against a regular expression and only reset the stopwatch (`delta`, `deltaSecs`, `deltaNanos`) when a line matches.
202
+
Using `-read-json`, you can tell `tj`to parse stdin as a sequence of JSON objects. The parsed object can be referred to via `.Object`, like this:
173
203
174
-
The regular expression can be specified via the `-start` parameter.
Using `-readjson`, you can tell `tj` to parse each input line as a separate JSON object. Fields of this object can be referred to via `.Object` in the `line` struct, like this:
212
+
The exact JSON string that was parsed can be recovered using `.Text`:
Additionally, you can also specify a template `-jsontemplate` to extract text from the object. The output of this template is matched against the stopwatch regex.
223
+
### Stopwatch regex
224
+
225
+
Sometimes you need to measure the duration between certain *tokens* in the input.
226
+
227
+
To help with this, `tj` can match each line against a regular expression and only reset the stopwatch (`delta`, `deltaSecs`, `deltaNanos`) when a line matches. The regular expression can be specified via the `-match-regex` (alias `-regex`) parameter.
228
+
229
+
### Stopwatch regex template
189
230
190
-
This allows you to use only specific fields of the object as stopwatch reset triggers. For example:
231
+
When using `-match-regex`, you can also specify a template `-match-template` (alias `-match`) to extract text from the current token. The output of this template is matched against the stopwatch regex.
232
+
233
+
This allows you to use only specific fields of JSON objects as stopwatch reset triggers. For example:
Additionally to `-match-regex`, you can specify a `-match-condition` go template. If this template produces the literal string `true`, the stopwatch is reset - "matches" of the `-match-condition` are treated like matches of the `-match-regex`.
260
+
214
261
## Example
215
262
216
263
Finding the slowest step in a `docker build` (using `jq`):
0 commit comments