Documentation ¶
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type EventBuilder ¶
type EventBuilder interface { WithID(id string) EventBuilder WithKind(kind string) EventBuilder WithSessionID(session string) EventBuilder WithTimeStamp(ts time.Time) EventBuilder WithPayload(payload any) EventBuilder Build() *Event }
EventBuilder helps to assemble events. The builder will create a universally unique ID (UUID) for the event ID if none is provided. Furthermore, the Timestamp will be set to 'now' in case it was not provided.
func NewEventBuilder ¶
func NewEventBuilder() EventBuilder
type EventLogger ¶
Example ¶
package main import ( "github.com/trichner/elog" "github.com/trichner/elog/csv" "os" "time" ) func main() { // create a new logger with the CSV backend logger, err := csv.NewCsvEventLogger(os.Stdout) if err != nil { panic(err) } event := elog.NewEventBuilder(). WithKind("user_login"). WithTimeStamp(time.Now()). WithPayload(map[string]string{ "user": "Alice", "remote": "42.0.4.23", }). Build() logger.Log(event) }
Output:
func NewNoOpEventLogger ¶
func NewNoOpEventLogger() EventLogger
Click to show internal directories.
Click to hide internal directories.