Skip to content

Commit

Permalink
consume: print message metadata if --raw is not set
Browse files Browse the repository at this point in the history
  • Loading branch information
birdayz committed Nov 25, 2018
1 parent 2786eb0 commit e84ae68
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions cmd/kaf/consume.go
Original file line number Diff line number Diff line change
Expand Up @@ -129,10 +129,11 @@ var consumeCmd = &cobra.Command{
}

if msg.Key != nil && len(msg.Key) > 0 && !raw {
fmt.Printf("%v %v\n", string(msg.Key), string(dataToDisplay))
} else {
fmt.Printf("%v\n", string(dataToDisplay))
w := tabwriter.NewWriter(os.Stderr, tabwriterMinWidth, tabwriterWidth, tabwriterPadding, tabwriterPadChar, tabwriterFlags)
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)
w.Flush()
}
fmt.Printf("%v\n", string(dataToDisplay))
}
wg.Done()
}(partition)
Expand Down

0 comments on commit e84ae68

Please sign in to comment.