-
Notifications
You must be signed in to change notification settings - Fork 4.7k
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
Avoid formatting in the binary output #942
Comments
No sure I understand what is the binary format. |
Example In the perfect world I would like to have a way to do something like auto my_logger = spdlog::binary_logger("binary_logger", "logs/basic-log.bin");
// Outputs 64 bits hash of the format string "Hello %s"
// and a null terminated string "world" to the file "logs/basic-log.bin"
my_logger->info("Hello: %s", "world"); My assumptions
Objectives When logging binary data (instead of outputting of human readable lines) I have two objectives
The idea In the binary logging mode I can log only the variadic part of the logger arguments. In the binary logging mode I output "encoded" data. I can "decode" the log data on demand given the binary log itself and some additional input generated at compilation time. Think about data serialization applied to logging. If I need a completely transparent way to consume binary logs by a human being I can add a user space filesystem which decodes log files on the go. When a user types The approach I suggest only looks revolutionary. It is used quite often in systems with tight requirements for the response latency. I am surprised that I can not find open source which targets this use case. |
Take a look at nanolog. It does what you need. |
We do not have to output constant format strings at all in the binary format. There are two possibilities
In the first approach application does not analyse the format strings. In the first approach format strings will not be part of the executable file (the .text section of the ELF is going to be smaller).
In the second approach the application analyses every format string once, keeps all required for output to the binary stream information.
In both approaches the application outputs only variadic arguments.
Both approaches limit the application to use immutable format strings, and, for the best performance, constant strings. The upside is x2-x4 performance gain and a smaller log.
The text was updated successfully, but these errors were encountered: