go.charczuk.com@v0.0.0-20240327042549-bc490516bd1a/sdk/simutil/spew_events.go (about) 1 /* 2 3 Copyright (c) 2023 - Present. Will Charczuk. All rights reserved. 4 Use of this source code is governed by a MIT license that can be found in the LICENSE file at the root of the repository. 5 6 */ 7 8 package simutil 9 10 import ( 11 "context" 12 "fmt" 13 "time" 14 ) 15 16 // SpewEvents prints events produced by a channel to stdout. 17 func SpewEvents[T any](ctx context.Context, from chan Event[T]) { 18 ReadEvents[T](ctx, from, func(_ context.Context, e Event[T]) { 19 fmt.Printf("%v: %#v\n", e.Timestamp.Format(time.RFC3339), e.Event) 20 }) 21 }