Skip to content

Commit 58b4021

Browse files
jschwinger233brb
authored andcommitted
Print TUPLE with historical max length
So that the following FUNC can be aligned Signed-off-by: gray <[email protected]>
1 parent b123b02 commit 58b4021

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

internal/pwru/output.go

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -346,6 +346,16 @@ func getOutFuncName(o *output, event *Event, addr uint64) string {
346346
return outFuncName
347347
}
348348

349+
var maxTupleLengthSeen int
350+
351+
func fprintTupleData(writer *os.File, tupleData string) {
352+
if len(tupleData) > maxTupleLengthSeen {
353+
maxTupleLengthSeen = len(tupleData)
354+
}
355+
formatter := fmt.Sprintf(" %%-%ds", maxTupleLengthSeen)
356+
fmt.Fprintf(writer, formatter, tupleData)
357+
}
358+
349359
func (o *output) Print(event *Event) {
350360
if o.flags.OutputTS == "absolute" {
351361
fmt.Fprintf(o.writer, "%-12s ", getAbsoluteTs())
@@ -375,7 +385,7 @@ func (o *output) Print(event *Event) {
375385
}
376386

377387
if o.flags.OutputTuple {
378-
fmt.Fprintf(o.writer, " %s", getTupleData(event))
388+
fprintTupleData(o.writer, getTupleData(event))
379389
}
380390

381391
fmt.Fprintf(o.writer, " %s", outFuncName)

0 commit comments

Comments
 (0)