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 change timestamp format in the JSON-formatted console message? #636

Closed
ksqrtr opened this issue Dec 27, 2024 · 2 comments
Closed

Comments

@ksqrtr
Copy link

ksqrtr commented Dec 27, 2024

Hi!
I'd like to use more human readable format like RFC 3339. Is it possible?

@odygrd
Copy link
Owner

odygrd commented Dec 27, 2024

For v7 you need to implement your own custom json sink with the desired formatting

copy paste this class
https://github.com/odygrd/quill/blob/master/include/quill/sinks/JsonFileSink.h

Or this class

https://github.com/odygrd/quill/blob/master/include/quill/sinks/JsonConsoleSink.h

And provide your own formatting eg here

_json_message.append(fmtquill::format(

Here is an example using a custom sink (in your case the copy pasted json sink)

auto file_sink = quill::Frontend::create_or_get_sink<UserSink>("sink_id_1");

There is an implemented change for v8 that lets you customise that without having to duplicate

QUILL_ATTRIBUTE_HOT virtual void generate_json_message(
but i am planning to release it in the next few months so I’d recommend doing your own sink for now

Let me know if you need any further help

@ksqrtr
Copy link
Author

ksqrtr commented Dec 29, 2024

Thanks a lot, I'll do what you have suggested till v8 is released.

@ksqrtr ksqrtr closed this as completed Dec 29, 2024
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