mirror of
https://github.com/libsdl-org/SDL.git
synced 2025-11-10 20:45:05 +00:00
log: Rework NGAGE logging. (#14321)
This moves the NGAGE file logging into SDL_LogOutput(), following the pattern of the 3DS, VITA, PSP, etc.
This commit is contained in:
@@ -24,6 +24,10 @@
|
||||
#include "core/windows/SDL_windows.h"
|
||||
#endif
|
||||
|
||||
#if defined(SDL_PLATFORM_NGAGE)
|
||||
#include "core/ngage/SDL_ngage.h"
|
||||
#endif
|
||||
|
||||
// Simple log messages in SDL
|
||||
|
||||
#include "SDL_log_c.h"
|
||||
@@ -598,25 +602,6 @@ void SDL_LogMessageV(int category, SDL_LogPriority priority, SDL_PRINTF_FORMAT_S
|
||||
return;
|
||||
}
|
||||
|
||||
#if defined(SDL_PLATFORM_NGAGE)
|
||||
extern void NGAGE_vnprintf(char *buf, size_t size, const char *fmt, va_list ap);
|
||||
char buf[1024];
|
||||
NGAGE_vnprintf(buf, sizeof(buf), fmt, ap);
|
||||
|
||||
#ifdef ENABLE_FILE_LOG
|
||||
FILE* file;
|
||||
file = fopen("E:/SDL_Log.txt", "a");
|
||||
if (file)
|
||||
{
|
||||
vfprintf(file, fmt, ap);
|
||||
fprintf(file, "\n");
|
||||
(void)fclose(file);
|
||||
}
|
||||
#endif
|
||||
|
||||
return;
|
||||
#endif
|
||||
|
||||
// Render into stack buffer
|
||||
va_copy(aq, ap);
|
||||
len = SDL_vsnprintf(stack_buf, sizeof(stack_buf), fmt, aq);
|
||||
@@ -799,7 +784,15 @@ static void SDLCALL SDL_LogOutput(void *userdata, int category, SDL_LogPriority
|
||||
}
|
||||
#elif defined(SDL_PLATFORM_NGAGE)
|
||||
{
|
||||
/* Nothing to do here. */
|
||||
NGAGE_DebugPrintf("%s%s", GetLogPriorityPrefix(priority), message);
|
||||
#ifdef ENABLE_FILE_LOG
|
||||
FILE *pFile;
|
||||
pFile = fopen("E:/SDL_Log.txt", "a");
|
||||
if (pFile) {
|
||||
(void)fprintf(pFile, "%s%s\n", GetLogPriorityPrefix(priority), message);
|
||||
(void)fclose(pFile);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
#if defined(HAVE_STDIO_H) && \
|
||||
|
||||
@@ -36,13 +36,13 @@ bool NGAGE_IsClassicModel()
|
||||
return (0x101f8c19 == phone_id);
|
||||
}
|
||||
|
||||
void NGAGE_printf(const char *fmt, ...)
|
||||
void NGAGE_DebugPrintf(const char *fmt, ...)
|
||||
{
|
||||
char buffer[512] = { 0 };
|
||||
|
||||
va_list ap;
|
||||
va_start(ap, fmt);
|
||||
vsprintf(buffer, fmt, ap);
|
||||
(void)SDL_vsnprintf(buffer, sizeof(buffer), fmt, ap);
|
||||
va_end(ap);
|
||||
|
||||
TBuf<512> buf;
|
||||
@@ -51,21 +51,6 @@ void NGAGE_printf(const char *fmt, ...)
|
||||
RDebug::Print(_L("%S"), &buf);
|
||||
}
|
||||
|
||||
void NGAGE_vnprintf(char *buf, size_t size, const char *fmt, va_list ap)
|
||||
{
|
||||
char buffer[512] = { 0 };
|
||||
|
||||
vsprintf(buffer, fmt, ap);
|
||||
|
||||
TBuf<512> tbuf;
|
||||
tbuf.Copy(TPtrC8((TText8 *)buffer));
|
||||
|
||||
RDebug::Print(_L("%S"), &tbuf);
|
||||
|
||||
strncpy(buf, buffer, size - 1);
|
||||
buf[size - 1] = '\0';
|
||||
}
|
||||
|
||||
TInt NGAGE_GetFreeHeapMemory()
|
||||
{
|
||||
TInt free = 0;
|
||||
|
||||
@@ -28,6 +28,7 @@ extern "C" {
|
||||
#endif
|
||||
|
||||
bool NGAGE_IsClassicModel();
|
||||
void NGAGE_DebugPrintf(SDL_PRINTF_FORMAT_STRING const char *fmt, ...) SDL_PRINTF_VARARG_FUNC(1);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user