mirror of
https://github.com/wiiu-env/ftpiiu_plugin.git
synced 2024-11-17 18:29:19 +01:00
Add logging support
This commit is contained in:
parent
20f29f60b8
commit
6a4b4f0355
@ -25,6 +25,8 @@ console_init(void)
|
||||
consoleSetWindow(&main_console, 0, 1, 50, 29);
|
||||
|
||||
consoleSelect(&main_console);
|
||||
|
||||
consoleDebugInit(debugDevice_NULL);
|
||||
}
|
||||
|
||||
/*! set status bar contents
|
||||
@ -40,6 +42,7 @@ console_set_status(const char *fmt, ...)
|
||||
consoleSelect(&status_console);
|
||||
va_start(ap, fmt);
|
||||
vprintf(fmt, ap);
|
||||
vfprintf(stderr, fmt, ap);
|
||||
va_end(ap);
|
||||
consoleSelect(&main_console);
|
||||
}
|
||||
@ -56,6 +59,7 @@ console_print(const char *fmt, ...)
|
||||
|
||||
va_start(ap, fmt);
|
||||
vprintf(fmt, ap);
|
||||
vfprintf(stderr, fmt, ap);
|
||||
va_end(ap);
|
||||
}
|
||||
|
||||
|
48
source/ftp.c
48
source/ftp.c
@ -1150,6 +1150,31 @@ ftp_init(void)
|
||||
goto archive_fail;
|
||||
}
|
||||
|
||||
#if ENABLE_LOGGING
|
||||
/* initialize sdmc_dev */
|
||||
ret = sdmcInit();
|
||||
if(ret != 0)
|
||||
{
|
||||
console_print(RED "sdmcInit: 0x%08X\n" RESET, (unsigned int)ret);
|
||||
goto sdmc_fail;
|
||||
}
|
||||
|
||||
/* open log file */
|
||||
FILE *fp = freopen("/ftbrony.log", "wb", stderr);
|
||||
if(fp == NULL)
|
||||
{
|
||||
console_print(RED "freopen: 0x%08X\n" RESET, errno);
|
||||
goto stderr_fail;
|
||||
}
|
||||
|
||||
/* truncate log file */
|
||||
if(ftruncate(fileno(fp), 0) != 0)
|
||||
{
|
||||
console_print(RED "ftruncate: 0x%08X\n" RESET, errno);
|
||||
goto ftruncate_fail;
|
||||
}
|
||||
#endif
|
||||
|
||||
/* allocate buffer for SOC service */
|
||||
SOC_buffer = (u32*)memalign(SOC_ALIGN, SOC_BUFFERSIZE);
|
||||
if(SOC_buffer == NULL)
|
||||
@ -1260,6 +1285,18 @@ soc_fail:
|
||||
free(SOC_buffer);
|
||||
|
||||
memalign_fail:
|
||||
#ifdef ENABLE_LOGGING
|
||||
ftruncate_fail:
|
||||
if(fclose(stderr) != 0)
|
||||
console_print(RED "fclose: 0x%08X\n" RESET, errno);
|
||||
|
||||
stderr_fail:
|
||||
ret = sdmcExit();
|
||||
if(ret != 0)
|
||||
console_print(RED "sdmcExit: 0x%08X\n" RESET, (unsigned int)ret);
|
||||
|
||||
sdmc_fail:
|
||||
#endif
|
||||
ret = FSUSER_CloseArchive(NULL, &sdmcArchive);
|
||||
if(ret != 0)
|
||||
console_print(RED "FSUSER_CloseArchive: 0x%08X\n" RESET, (unsigned int)ret);
|
||||
@ -1297,6 +1334,17 @@ ftp_exit(void)
|
||||
console_print(RED "SOC_Shutdown: 0x%08X\n" RESET, (unsigned int)ret);
|
||||
free(SOC_buffer);
|
||||
|
||||
#ifdef ENABLE_LOGGING
|
||||
/* close log file */
|
||||
if(fclose(stderr) != 0)
|
||||
console_print(RED "fclose: 0x%08X\n" RESET, errno);
|
||||
|
||||
/* deinitialize sdmc_dev
|
||||
ret = sdmcExit();
|
||||
if(ret != 0)
|
||||
console_print(RED "sdmcExit: 0x%08X\n" RESET, (unsigned int)ret);
|
||||
#endif
|
||||
|
||||
/* deinitialize FS service */
|
||||
ret = fsExit();
|
||||
if(ret != 0)
|
||||
|
Loading…
Reference in New Issue
Block a user