I made a lot of progress. I decided to use a static array of up to 16 arguments (should be more than enough, but I might still change this to a vector for infinitely many arguments). I chose to take the route to do formatting one argument at a time, e.g.:
Code:
for each argument in array:
switch argument:
case LOG_ARG_TIME: snprintf(buffer, len, format, time); break;
case LOG_ARG_DATE: snprintf(buffer, len, format, date); break;
...
This has an issue where copying is not working as expected. I would like it to just replace the first instance of
%s with the current argument and return the number of characters copied, however it returns a negative number instead (as per the specification because it isn't copying the entire string). I will need to get this working by keeping track of the current lengths and carefully incrementing. E.g. iteration sequence:
Code:
%s_%s
^
logger_%s
^
logger_2015-09-13
^
I have this working for the time and date fields right now, but the others do not work yet. I also need to add the fill-in values for the calling function and plugin.
__________________