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

Console writer does not use defined timestamp formatter #494

Open
gucki opened this issue Oct 13, 2022 · 2 comments
Open

Console writer does not use defined timestamp formatter #494

gucki opened this issue Oct 13, 2022 · 2 comments

Comments

@gucki
Copy link

gucki commented Oct 13, 2022

The console writer is not using the timestamp formatter for fields:

log.Ctx(ctx).Warn().Time("expiredAt", time.Now()).Msgf("something expired")

Outputs:

2022-10-13T10:34:16+02:00 WRN something expired expiredAt=1665650056

Imo, expected would be:

2022-10-13T10:34:16+02:00 WRN something expired expiredAt=2022-10-13T10:34:16+02:00
@luxinxinxin
Copy link

It is determined by zerolog.TimeFieldFormat.

@mitar
Copy link
Contributor

mitar commented Aug 18, 2023

TimeFieldFormat is used to determine how timestamp is stored in JSON. Which is then parsed and formatted for the console for console writer. So the question here is: how you want to store timestamps in JSON and how you want to have them shown in console. So are you complaining only about the console? You can configure FormatFieldValue to format non-timestamp time fields differently.

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

3 participants