log.zig icon indicating copy to clipboard operation
log.zig copied to clipboard

Improved timestamp formatting

Open demizer opened this issue 4 years ago • 1 comments

The Unix Epoch time is not human readable. I suggest this library allow users to change the timestamp format to whatever they like. https://github.com/gernest/time is a Zig port of the Go time package that gives users the ability to format a timestamp in any whatever way they like. I am new to Zig so I am uncertain how package dependencies work, but perhaps log.zig could detect if the time library is linked to a binary and expose options to the user? I'll work on creating a PR.

demizer avatar May 04 '20 01:05 demizer

POC commits of above have output like:

2020-05-11T21:27:06-07:00 [INFO]: FOO
2020-05-11T21:27:06-07:00 [INFO]: BAR
2020-05-11T21:27:06-07:00 [WARN]: BAZ
2020-05-11T21:27:06-07:00 [ERROR]: An error occurred!

This allows users to set a date handler function to format dates without adding dependencies to log.zig itself.

demizer avatar May 12 '20 04:05 demizer