Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

how to get Event timestamp in hook Run() ? #679

Open
zhujintao opened this issue Jul 4, 2024 · 0 comments
Open

how to get Event timestamp in hook Run() ? #679

zhujintao opened this issue Jul 4, 2024 · 0 comments

Comments

@zhujintao
Copy link

suggestion is to use the function in the file event.go

func (e *Event) Timestamp() *Event {
	if e == nil {
		return e
	}
	t := TimestampFunc()
	ctx := context.WithValue(e.GetCtx(), "time", t)
	e.Ctx(ctx)
	e.buf = enc.AppendTime(enc.AppendKey(e.buf, TimestampFieldName), t, TimeFieldFormat)
	return e
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant