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 output "0216-15:28:03+08:05" #524

Open
luxinxinxin opened this issue Feb 16, 2023 · 1 comment
Open

Console output "0216-15:28:03+08:05" #524

luxinxinxin opened this issue Feb 16, 2023 · 1 comment

Comments

@luxinxinxin
Copy link

When I set zerolog.TimeFieldFormat = "0102-15:04:05Z07" and zerolog.ConsoleWriter.TimeFormat = "0102-15:04:05Z07:00" ,the console output "0216-15:28:03+08:05" at 20230216-15:22:20+08. I try to find the cause of the problem, I found the function consoleDefaultFormatTimestamp in console.go line 340, it use "0216-15:28:03+08" as an argument to the function time.Parse(),so it considers "0216-15:28:03+08" equal to "0000-0216-15:28:03+08". I think it should use a variable of type time.Time as parameter not string. but I can avoid this problem when I set zerolog.TimeFieldFormat = "060102-15:04:05Z07" . I find this problem on linux(ubuntu18.04.1) system, but windows system looks normal. On windows. the console output "0216-15:22:20+08:00" at 20230216-15:22:20+08.

@mitar
Copy link
Contributor

mitar commented Aug 18, 2023

I think your problem is that you are using TimeFieldFormat without a year field. This leads to many issues. TimeFieldFormat is used for JSON field. There you should keep year. If you want to change how dates are written do the console only, do not change TimeFieldFormat.

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