I am trying to do some investigation on some external hardware which doesn't have logging.
For this I am making my own small logger using varargs in C. This is my code:
void write(const char* msg, ...)
{
va_list args;
va_start(args, msg);
FILE* file = fopen("/network/cewin/loggerfile.txt", "a");
if(file != NULL)
{
vfprintf(file, msg, args);
fputc('\n', file);
fclose(file);
va_end(args);
}
}
First I test this code on Windows 7, without issue, but on WinCE the lines containing arguments are not printed.
Here is an example:
write("Hello World") - Works on Win 7 and WinCE
write("Hello %s", "World") - Works on Win7, not on WinCE
write("Hello %i", 5) - Works on Win7, not on WinCE
I am trying to understand why the last 2 lines are working on Win7 but not on WinCE. Maybe I need to use something else than vfprintf
?
I cannot check the return values from methods, because of HW.
Not an answer -> I can't put code in comments - 'static' debug function, does not use varargs or vnprintf
void debugI(char *str, int iValue)
{
FILE *debugPtr = fopen ("/debugpath/debugFile.txt", "a");
fprintf (debugPtr, "debugI %s:%d\n", str, iValue);
fclose (debugPtr);
}