Send raylib logs to stderr by default

from man stderr:

       Under  normal circumstances every UNIX program has three streams opened
       for it when it starts up, one for input, one for output,  and  one  for
       printing diagnostic or error messages.

It's a more appropriate place for programs to send logs, as it's a
stream meant explicitly for it.

stderr is unbuffered, so it doesn't need to be flushed.
This commit is contained in:
Peter0x44 2024-01-23 00:35:47 +00:00
parent cb97a8063d
commit 9ab99bccd6

View File

@ -45,7 +45,7 @@
#endif #endif
#include <stdlib.h> // Required for: exit() #include <stdlib.h> // Required for: exit()
#include <stdio.h> // Required for: FILE, fopen(), fseek(), ftell(), fread(), fwrite(), fprintf(), vprintf(), fclose() #include <stdio.h> // Required for: FILE, fopen(), fseek(), ftell(), fread(), fwrite(), fprintf(), vfprintf(), fclose()
#include <stdarg.h> // Required for: va_list, va_start(), va_end() #include <stdarg.h> // Required for: va_list, va_start(), va_end()
#include <string.h> // Required for: strcpy(), strcat() #include <string.h> // Required for: strcpy(), strcat()
@ -147,8 +147,7 @@ void TraceLog(int logType, const char *text, ...)
unsigned int textSize = (unsigned int)strlen(text); unsigned int textSize = (unsigned int)strlen(text);
memcpy(buffer + strlen(buffer), text, (textSize < (MAX_TRACELOG_MSG_LENGTH - 12))? textSize : (MAX_TRACELOG_MSG_LENGTH - 12)); memcpy(buffer + strlen(buffer), text, (textSize < (MAX_TRACELOG_MSG_LENGTH - 12))? textSize : (MAX_TRACELOG_MSG_LENGTH - 12));
strcat(buffer, "\n"); strcat(buffer, "\n");
vprintf(buffer, args); vfprintf(stderr, buffer, args);
fflush(stdout);
#endif #endif
va_end(args); va_end(args);