Skip to content

Commit e81f7a3

Browse files
committed
Adjust raft-testlog-viz to handle part 4
1 parent 0bf3247 commit e81f7a3

File tree

1 file changed

+17
-3
lines changed

1 file changed

+17
-3
lines changed

tools/raft-testlog-viz/main.go

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,7 @@ func parseTestLogs(rd io.Reader) []TestLog {
224224
var testlogs []TestLog
225225

226226
statusRE := regexp.MustCompile(`--- (\w+):\s+(\w+)`)
227-
entryRE := regexp.MustCompile(`([0-9:.]+) \[(\w+)\] (.*)`)
227+
entryRE := regexp.MustCompile(`([0-9:.]+) \[([\w ]+)\] (.*)`)
228228

229229
scanner := bufio.NewScanner(bufio.NewReader(rd))
230230
for scanner.Scan() {
@@ -249,10 +249,24 @@ func parseTestLogs(rd io.Reader) []TestLog {
249249

250250
entryMatch := entryRE.FindStringSubmatch(line)
251251
if len(entryMatch) > 0 {
252+
// [kv N] entries get folded into id=N, with the "kv N" part prefixed
253+
// to the message.
254+
id, foundKV := strings.CutPrefix(entryMatch[2], "kv ")
255+
msg := entryMatch[3]
256+
if foundKV {
257+
msg = id + " " + msg
258+
}
259+
260+
// [clientNNN] entries get folded into id=TEST
261+
if strings.HasPrefix(entryMatch[2], "client") {
262+
id = "TEST"
263+
msg = entryMatch[2] + " " + msg
264+
}
265+
252266
entry := Entry{
253267
timestamp: entryMatch[1],
254-
id: entryMatch[2],
255-
msg: entryMatch[3],
268+
id: id,
269+
msg: msg,
256270
}
257271
curlog.entries = append(curlog.entries, entry)
258272
curlog.ids[entry.id] = true

0 commit comments

Comments
 (0)