[spu2null, padnull, gsnull, zzogl]: use the setLogDir API to select the log path.

git-svn-id: http://pcsx2.googlecode.com/svn/trunk@3203 96395faa-99c1-11dd-bbfe-3dabce05a288
This commit is contained in:
gregory.hainaut 2010-06-11 17:31:45 +00:00
parent b43d8b650f
commit 1e9be9eab2
4 changed files with 119 additions and 31 deletions

View File

@ -38,6 +38,7 @@ u32 GSKeyEvent = 0;
bool GSShift = false, GSAlt = false; bool GSShift = false, GSAlt = false;
string s_strIniPath="inis"; string s_strIniPath="inis";
std::string s_strLogPath("logs/");
const char* s_iniFilename = "GSnull.ini"; const char* s_iniFilename = "GSnull.ini";
// Because I haven't bothered to get GSOpen2 working in Windows yet in GSNull. // Because I haven't bothered to get GSOpen2 working in Windows yet in GSNull.
@ -62,6 +63,24 @@ EXPORT_C_(u32) PS2EgetLibVersion2(u32 type)
return (version<<16) | (revision<<8) | build; return (version<<16) | (revision<<8) | build;
} }
bool OpenLog() {
bool result = true;
#ifdef GS_LOG
const std::string LogFile(s_strLogPath + "GSnull.log");
gsLog = fopen(LogFile.c_str(), "w");
if (gsLog != NULL)
setvbuf(gsLog, NULL, _IONBF, 0);
else {
SysMessage("Can't create log file %s\n", LogFile.c_str());
result = false;
}
GS_LOG("GSnull plugin version %d,%d\n",revision,build);
GS_LOG("GS init\n");
#endif
return result;
}
void __Log(char *fmt, ...) void __Log(char *fmt, ...)
{ {
va_list list; va_list list;
@ -105,16 +124,21 @@ EXPORT_C_(void) GSsetSettingsDir(const char* dir)
s_strIniPath = (dir == NULL) ? "inis/" : dir; s_strIniPath = (dir == NULL) ? "inis/" : dir;
} }
EXPORT_C_(void) GSsetLogDir(const char* dir)
{
// Get the path to the log directory.
s_strLogPath = (dir==NULL) ? "logs/" : dir;
// Reload the log file after updated the path
if (gsLog != NULL) fclose(gsLog);
OpenLog();
}
EXPORT_C_(s32) GSinit() EXPORT_C_(s32) GSinit()
{ {
LoadConfig(); LoadConfig();
#ifdef GS_LOG OpenLog();
gsLog = fopen("logs/gsLog.txt", "w");
if (gsLog) setvbuf(gsLog, NULL, _IONBF, 0);
GS_LOG("GSnull plugin version %d,%d\n",revision,build);
GS_LOG("GS init\n");
#endif
SysPrintf("Initializing GSnull\n"); SysPrintf("Initializing GSnull\n");
return 0; return 0;

View File

@ -27,6 +27,7 @@ const u8 build = 1; // increase that with each version
static char *libraryName = "Padnull Driver"; static char *libraryName = "Padnull Driver";
string s_strIniPath="inis/"; string s_strIniPath="inis/";
string s_strLogPath="logs/";
FILE *padLog; FILE *padLog;
Config conf; Config conf;
@ -76,18 +77,40 @@ EXPORT_C_(void) PADsetSettingsDir(const char* dir)
s_strIniPath = (dir == NULL) ? "inis/" : dir; s_strIniPath = (dir == NULL) ? "inis/" : dir;
} }
bool OpenLog() {
bool result = true;
#ifdef PAD_LOG
if(padLog) return result;
const std::string LogFile(s_strLogPath + "/padnull.log");
padLog = fopen(LogFile.c_str(), "w");
if (padLog != NULL)
setvbuf(padLog, NULL, _IONBF, 0);
else {
SysMessage("Can't create log file %s\n", LogFile.c_str());
result = false;
}
PAD_LOG("PADinit\n");
#endif
return result;
}
EXPORT_C_(void) PADsetLogDir(const char* dir)
{
// Get the path to the log directory.
s_strLogPath = (dir==NULL) ? "logs/" : dir;
// Reload the log file after updated the path
if (padLog) fclose(padLog);
OpenLog();
}
EXPORT_C_(s32) PADinit(u32 flags) EXPORT_C_(s32) PADinit(u32 flags)
{ {
LoadConfig(); LoadConfig();
#ifdef PAD_LOG OpenLog();
if (padLog == NULL)
{
padLog = fopen("logs/padLog.txt", "w");
if (padLog) setvbuf(padLog, NULL, _IONBF, 0);
}
PAD_LOG("PADinit\n");
#endif
return 0; return 0;
} }

View File

@ -41,6 +41,7 @@ char *libraryName = "SPU2null (Debug)";
char *libraryName = "SPU2null "; char *libraryName = "SPU2null ";
#endif #endif
string s_strIniPath="inis/"; string s_strIniPath="inis/";
string s_strLogPath="logs/";
FILE *spu2Log; FILE *spu2Log;
Config conf; Config conf;
@ -114,14 +115,40 @@ EXPORT_C_(void) SPU2setSettingsDir(const char* dir)
s_strIniPath = (dir == NULL) ? "inis/" : dir; s_strIniPath = (dir == NULL) ? "inis/" : dir;
} }
EXPORT_C_(s32) SPU2init() bool OpenLog() {
{ bool result = true;
#ifdef SPU2_LOG #ifdef SPU2_LOG
spu2Log = fopen("logs/spu2.txt", "w"); if(spu2Log) return result;
if (spu2Log) setvbuf(spu2Log, NULL, _IONBF, 0);
const std::string LogFile(s_strLogPath + "/spu2null.log");
spu2Log = fopen(LogFile.c_str(), "w");
if (spu2Log != NULL)
setvbuf(spu2Log, NULL, _IONBF, 0);
else {
SysMessage("Can't create log file %s\n", LogFile.c_str());
result = false;
}
SPU2_LOG("Spu2 null version %d,%d\n", revision, build); SPU2_LOG("Spu2 null version %d,%d\n", revision, build);
SPU2_LOG("SPU2init\n"); SPU2_LOG("SPU2init\n");
#endif #endif
return result;
}
EXPORT_C_(void) SPU2setLogDir(const char* dir)
{
// Get the path to the log directory.
s_strLogPath = (dir==NULL) ? "logs/" : dir;
// Reload the log file after updated the path
if (spu2Log) fclose(spu2Log);
OpenLog();
}
EXPORT_C_(s32) SPU2init()
{
OpenLog();
spu2regs = (s8*)malloc(0x10000); spu2regs = (s8*)malloc(0x10000);
if (spu2regs == NULL) if (spu2regs == NULL)
{ {

View File

@ -58,6 +58,7 @@ void (*GSirq)();
u8* g_pBasePS2Mem = NULL; u8* g_pBasePS2Mem = NULL;
int g_TransferredToGPU = 0; int g_TransferredToGPU = 0;
std::string s_strIniPath("inis/"); // Air's new ini path (r2361) std::string s_strIniPath("inis/"); // Air's new ini path (r2361)
std::string s_strLogPath("logs/");
int g_GameSettings = 0; int g_GameSettings = 0;
int CurrentSavestate = 0; // Number of SaveSlot. Default is 0 int CurrentSavestate = 0; // Number of SaveSlot. Default is 0
@ -124,6 +125,21 @@ bool IsLogging()
return (gsLog != NULL && conf.log); return (gsLog != NULL && conf.log);
} }
bool OpenLog() {
bool result = true;
const std::string LogFile(s_strLogPath + "GSzzogl.log");
gsLog = fopen(LogFile.c_str(), "w");
if (gsLog != NULL)
setvbuf(gsLog, NULL, _IONBF, 0);
else {
SysMessage("Can't create log file %s\n", LogFile.c_str());
result = false;
}
return result;
}
void WriteToScreen(const char* pstr, u32 ms) void WriteToScreen(const char* pstr, u32 ms)
{ {
ZeroGS::AddMessage(pstr, ms); ZeroGS::AddMessage(pstr, ms);
@ -333,6 +349,16 @@ void CALLBACK GSsetSettingsDir(const char* dir)
s_strIniPath = (dir == NULL) ? "inis/" : dir; s_strIniPath = (dir == NULL) ? "inis/" : dir;
} }
void CALLBACK GSsetLogDir(const char* dir)
{
// Get the path to the log directory.
s_strLogPath = (dir==NULL) ? "logs/" : dir;
// Reload the log file after updated the path
if (gsLog != NULL) fclose(gsLog);
ZZLog::OpenLog();
}
extern int VALIDATE_THRESH; extern int VALIDATE_THRESH;
extern u32 TEXDESTROY_THRESH; extern u32 TEXDESTROY_THRESH;
@ -465,20 +491,8 @@ s32 CALLBACK GSinit()
memcpy(g_GIFTempRegHandlers, g_GIFPackedRegHandlers, sizeof(g_GIFTempRegHandlers)); memcpy(g_GIFTempRegHandlers, g_GIFPackedRegHandlers, sizeof(g_GIFTempRegHandlers));
gsLog = fopen("logs/gsLog.txt", "w"); if (ZZLog::OpenLog() == false)
if (gsLog == NULL)
{
gsLog = fopen("gsLog.txt", "w");
if (gsLog == NULL)
{
SysMessage("Can't create gsLog.txt");
return -1; return -1;
}
}
setvbuf(gsLog, NULL, _IONBF, 0);
ZZLog::GS_Log("Calling GSinit."); ZZLog::GS_Log("Calling GSinit.");