Skip to content

Commit

Permalink
Print TUPLE with historical max length
Browse files Browse the repository at this point in the history
So that the following FUNC can be aligned

Signed-off-by: gray <[email protected]>
  • Loading branch information
jschwinger233 authored and brb committed May 28, 2024
1 parent b123b02 commit 58b4021
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion internal/pwru/output.go
Original file line number Diff line number Diff line change
Expand Up @@ -346,6 +346,16 @@ func getOutFuncName(o *output, event *Event, addr uint64) string {
return outFuncName
}

var maxTupleLengthSeen int

func fprintTupleData(writer *os.File, tupleData string) {
if len(tupleData) > maxTupleLengthSeen {
maxTupleLengthSeen = len(tupleData)
}
formatter := fmt.Sprintf(" %%-%ds", maxTupleLengthSeen)
fmt.Fprintf(writer, formatter, tupleData)
}

func (o *output) Print(event *Event) {
if o.flags.OutputTS == "absolute" {
fmt.Fprintf(o.writer, "%-12s ", getAbsoluteTs())
Expand Down Expand Up @@ -375,7 +385,7 @@ func (o *output) Print(event *Event) {
}

if o.flags.OutputTuple {
fmt.Fprintf(o.writer, " %s", getTupleData(event))
fprintTupleData(o.writer, getTupleData(event))
}

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

0 comments on commit 58b4021

Please sign in to comment.