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

Set / modify time format per logger instance #487

Open
v-byte-cpu opened this issue Oct 2, 2022 · 2 comments
Open

Set / modify time format per logger instance #487

v-byte-cpu opened this issue Oct 2, 2022 · 2 comments

Comments

@v-byte-cpu
Copy link

v-byte-cpu commented Oct 2, 2022

I would like to change a time format for different logger instances, but currently the time format is set by the global constant zerolog.TimeFieldFormat and used explicitly in timestamp hook

zerolog/event.go

Lines 647 to 653 in 55aaf04

func (e *Event) Timestamp() *Event {
if e == nil {
return e
}
e.buf = enc.AppendTime(enc.AppendKey(e.buf, TimestampFieldName), TimestampFunc(), TimeFieldFormat)
return e
}
:

@phuslu
Copy link

phuslu commented Oct 21, 2022

You catch it, that's one reason of why I re-write another similar logger instead of forking. maybe worth see https://github.com/phuslu/log#logger

@v-byte-cpu
Copy link
Author

seems pretty good, will try it soon

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

2 participants