Skip to content

Commit e84ae68

Browse files
committed
consume: print message metadata if --raw is not set
1 parent 2786eb0 commit e84ae68

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

cmd/kaf/consume.go

+4-3
Original file line numberDiff line numberDiff line change
@@ -129,10 +129,11 @@ var consumeCmd = &cobra.Command{
129129
}
130130

131131
if msg.Key != nil && len(msg.Key) > 0 && !raw {
132-
fmt.Printf("%v %v\n", string(msg.Key), string(dataToDisplay))
133-
} else {
134-
fmt.Printf("%v\n", string(dataToDisplay))
132+
w := tabwriter.NewWriter(os.Stderr, tabwriterMinWidth, tabwriterWidth, tabwriterPadding, tabwriterPadChar, tabwriterFlags)
133+
fmt.Fprintf(w, "Key:\t%v\nPartition:\t%v\nOffset:\t%v\nTimestamp:\t%v\n", string(msg.Key), msg.Partition, msg.Offset, msg.Timestamp)
134+
w.Flush()
135135
}
136+
fmt.Printf("%v\n", string(dataToDisplay))
136137
}
137138
wg.Done()
138139
}(partition)

0 commit comments

Comments
 (0)