mirror of https://github.com/PCSX2/pcsx2.git
Merge pull request #601 from TheLastRar/dev9logging
Dev9ghz: Respect user Log dir setting, use PluginLog. Fixes init crashes
This commit is contained in:
commit
93168069db
|
@ -80,8 +80,15 @@ u32 CALLBACK PS2EgetLibVersion2(u32 type) {
|
||||||
return (version<<16) | (revision<<8) | build;
|
return (version<<16) | (revision<<8) | build;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//string s_strIniPath = "inis";
|
||||||
|
std::string s_strLogPath = "logs";
|
||||||
// Warning: The below log function is SLOW. Better fix it before attempting to use it.
|
// Warning: The below log function is SLOW. Better fix it before attempting to use it.
|
||||||
|
#ifdef _DEBUG
|
||||||
|
int Log = 1;
|
||||||
|
#else
|
||||||
int Log = 0;
|
int Log = 0;
|
||||||
|
#endif
|
||||||
|
|
||||||
void __Log(char *fmt, ...) {
|
void __Log(char *fmt, ...) {
|
||||||
if (!Log) return;
|
if (!Log) return;
|
||||||
|
@ -94,26 +101,31 @@ void __Log(char *fmt, ...) {
|
||||||
|
|
||||||
if(iopPC!=NULL)
|
if(iopPC!=NULL)
|
||||||
{
|
{
|
||||||
fprintf(dev9Log,"[%10d + %4d, IOP PC = %08x] ",nticks,nticks-ticks,*iopPC);
|
DEV9Log.Write("[%10d + %4d, IOP PC = %08x] ", nticks, nticks - ticks, *iopPC);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
fprintf(dev9Log,"[%10d + %4d] ",nticks,nticks-ticks);
|
DEV9Log.Write( "[%10d + %4d] ", nticks, nticks - ticks);
|
||||||
}
|
}
|
||||||
ticks=nticks;
|
ticks=nticks;
|
||||||
|
|
||||||
va_start(list, fmt);
|
va_start(list, fmt);
|
||||||
vfprintf(dev9Log, fmt, list);
|
DEV9Log.Write(fmt, list);
|
||||||
va_end(list);
|
va_end(list);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void LogInit()
|
||||||
|
{
|
||||||
|
const std::string LogFile(s_strLogPath + "/dev9Log.txt");
|
||||||
|
DEV9Log.WriteToFile = true;
|
||||||
|
DEV9Log.Open(LogFile);
|
||||||
|
}
|
||||||
|
|
||||||
s32 CALLBACK DEV9init()
|
s32 CALLBACK DEV9init()
|
||||||
{
|
{
|
||||||
|
|
||||||
#ifdef DEV9_LOG_ENABLE
|
#ifdef DEV9_LOG_ENABLE
|
||||||
dev9Log = fopen("logs/dev9Log.txt", "w");
|
LogInit();
|
||||||
setvbuf(dev9Log, NULL, _IONBF, 0);
|
|
||||||
DEV9_LOG("DEV9init\n");
|
DEV9_LOG("DEV9init\n");
|
||||||
#endif
|
#endif
|
||||||
memset(&dev9, 0, sizeof(dev9));
|
memset(&dev9, 0, sizeof(dev9));
|
||||||
|
@ -179,7 +191,7 @@ s32 CALLBACK DEV9init()
|
||||||
void CALLBACK DEV9shutdown() {
|
void CALLBACK DEV9shutdown() {
|
||||||
DEV9_LOG("DEV9shutdown\n");
|
DEV9_LOG("DEV9shutdown\n");
|
||||||
#ifdef DEV9_LOG_ENABLE
|
#ifdef DEV9_LOG_ENABLE
|
||||||
fclose(dev9Log);
|
DEV9Log.Close();
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -618,6 +630,16 @@ void CALLBACK DEV9setSettingsDir(const char* dir)
|
||||||
// s_strIniPath = (dir == NULL) ? "inis" : dir;
|
// s_strIniPath = (dir == NULL) ? "inis" : dir;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CALLBACK DEV9setLogDir(const char* dir)
|
||||||
|
{
|
||||||
|
// Get the path to the log directory.
|
||||||
|
s_strLogPath = (dir == NULL) ? "logs" : dir;
|
||||||
|
|
||||||
|
// Reload the log file after updated the path
|
||||||
|
// Currently dosn't change winPcap log directories post DEV9open()
|
||||||
|
DEV9Log.Close();
|
||||||
|
LogInit();
|
||||||
|
}
|
||||||
|
|
||||||
int emu_printf(const char *fmt, ...)
|
int emu_printf(const char *fmt, ...)
|
||||||
{
|
{
|
||||||
|
|
|
@ -17,6 +17,7 @@
|
||||||
#define __DEV9_H__
|
#define __DEV9_H__
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
#include <string>
|
||||||
#ifndef EXTERN
|
#ifndef EXTERN
|
||||||
#define EXTERN extern
|
#define EXTERN extern
|
||||||
#endif
|
#endif
|
||||||
|
@ -25,6 +26,7 @@
|
||||||
//#define _WIN32_WINNT 0x0500
|
//#define _WIN32_WINNT 0x0500
|
||||||
|
|
||||||
#include "PS2Edefs.h"
|
#include "PS2Edefs.h"
|
||||||
|
#include "PS2Eext.h"
|
||||||
#include "net.h"
|
#include "net.h"
|
||||||
|
|
||||||
#ifdef __WIN32__
|
#ifdef __WIN32__
|
||||||
|
@ -125,7 +127,9 @@ void _DEV9close();
|
||||||
EXTERN DEV9callback DEV9irq;
|
EXTERN DEV9callback DEV9irq;
|
||||||
//void DEV9thread();
|
//void DEV9thread();
|
||||||
|
|
||||||
EXTERN FILE *dev9Log;
|
EXTERN PluginLog DEV9Log;
|
||||||
|
//Yes this is meant to be a lowercase extern
|
||||||
|
extern std::string s_strLogPath;
|
||||||
void __Log(char *fmt, ...);
|
void __Log(char *fmt, ...);
|
||||||
|
|
||||||
void SysMessage(char *fmt, ...);
|
void SysMessage(char *fmt, ...);
|
||||||
|
|
|
@ -26,4 +26,5 @@ EXPORTS
|
||||||
DEV9irqHandler @21
|
DEV9irqHandler @21
|
||||||
DEV9async @22
|
DEV9async @22
|
||||||
|
|
||||||
DEV9setSettingsDir
|
DEV9setSettingsDir
|
||||||
|
DEV9setLogDir
|
|
@ -123,9 +123,13 @@ int pcap_io_init(char *adapter)
|
||||||
fprintf(stderr,"WARNING: Error setting non-blocking mode. Default mode will be used.\n");
|
fprintf(stderr,"WARNING: Error setting non-blocking mode. Default mode will be used.\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
packet_log=fopen("logs/packet.log","w");
|
//Changing the LogSetting might not affect logging
|
||||||
|
//directory of winPcap logs if done after Open()
|
||||||
|
const std::string pfile(s_strLogPath + "/packet.log");
|
||||||
|
packet_log = fopen(pfile.c_str(), "w");
|
||||||
|
|
||||||
dump_pcap = pcap_dump_open(adhandle,"logs/pkt_log.pcap");
|
const std::string plfile(s_strLogPath + "/pkt_log.pcap");
|
||||||
|
dump_pcap = pcap_dump_open(adhandle, plfile.c_str());
|
||||||
|
|
||||||
pcap_io_running=1;
|
pcap_io_running=1;
|
||||||
emu_printf("Ok.\n");
|
emu_printf("Ok.\n");
|
||||||
|
|
Loading…
Reference in New Issue