odygrd / quill

Asynchronous Low Latency C++ Logging Library
MIT License
1.55k stars 158 forks source link

How to log binary data #388

Closed jamespinkerton closed 7 months ago

jamespinkerton commented 10 months ago

Hi. I have a struct that contains only numbers (float's, uint32_t's, bool's, things like this).

I'd like to be able to log a sequence of these structs to a file with Quill. I'm using Quill extensively to log messages of strings and it's working very well. But I haven't been able to figure out how to use it to log raw data.

I'm sorry if this is actually obvious. Any help would be greatly appreciated!

James

qiuwei commented 9 months ago

Why not format it as json? then you can recover the struct easily from the log.

odygrd commented 7 months ago

hey sorry for the late response. It is not possible to log binary raw data, the backend thread will always try to format messages to human readable string before writing them to the log file. You format them on the hot path to hex (https://github.com/odygrd/quill/blob/master/quill/include/quill/Utility.h#L28) and then print them to the log file, that is more useful for debugging purposes