diff --git a/Source/Core/Common/Src/Log.h b/Source/Core/Common/Src/Log.h index d48cf7189f..83a022d7e7 100644 --- a/Source/Core/Common/Src/Log.h +++ b/Source/Core/Common/Src/Log.h @@ -61,7 +61,7 @@ enum LOG_TYPE { }; enum LOG_LEVELS { - LERROR = 0, // Bad errors - that still don't deserve a PanicAlert. + LERROR = 1, // Bad errors - that still don't deserve a PanicAlert. LWARNING, // Something is suspicious. LINFO, // General information. LDEBUG, // Strictly for detailed debugging - might make things slow. @@ -76,19 +76,44 @@ enum LOG_LEVELS { - Compile the log functions according to LOGLEVEL */ #ifdef LOGGING -#define LOGLEVEL 5 +#define LOGLEVEL 4 //LogTypes::LDEBUG +#else +#ifndef LOGLEVEL +#define LOGLEVEL 2 //LogTypes::LWARNING +#endif // loglevel +#endif // logging + +#define ERROR_LOG(...) +#define WARN_LOG(...) +#define INFO_LOG(...) +#define DEBUG_LOG(...) extern void __Log(int logNumber, const char* text, ...); // Let the compiler optimize this out -//#define GENERIC_LOG(t,v, ...) {if (v <= LOGLEVEL) __Log(t + (v)*100, __VA_ARGS__);} -#define GENERIC_LOG(t,v, ...) {__Log(t + (v)*100, __VA_ARGS__);} +#define GENERIC_LOG(t,v, ...) {if (v <= LOGLEVEL) __Log(t + (v)*100, __VA_ARGS__);} + +#if LOGLEVEL >= 1 //LogTypes::LERROR +#undef ERROR_LOG #define ERROR_LOG(t,...) {GENERIC_LOG(LogTypes::t, LogTypes::LERROR, __VA_ARGS__)} -#define WARN_LOG(t,...) {GENERIC_LOG(LogTypes::t, LogTypes::LINFO, __VA_ARGS__)} -#define INFO_LOG(t,...) {GENERIC_LOG(LogTypes::t, LogTypes::LWARNING, __VA_ARGS__)} +#endif // loglevel LERROR+ + +#if LOGLEVEL >= 2 //LogTypes::LWARNING +#undef WARN_LOG +#define WARN_LOG(t,...) {GENERIC_LOG(LogTypes::t, LogTypes::LWARNING, __VA_ARGS__)} +#endif // loglevel LWARNING+ + +#if LOGLEVEL >= 3 //LogTypes::LINFO +#undef INFO_LOG +#define INFO_LOG(t,...) {GENERIC_LOG(LogTypes::t, LogTypes::LINFO, __VA_ARGS__)} +#endif // loglevel LINFO+ + +#if LOGLEVEL >= 4 //LogTypes::LDEBUG +#undef DEBUG_LOG #define DEBUG_LOG(t,...) {GENERIC_LOG(LogTypes::t, LogTypes::LDEBUG, __VA_ARGS__)} +#endif // loglevel LDEBUG+ - +#if LOGLEVEL >= 4 //LogTypes::LDEBUG #define _dbg_assert_(_t_, _a_) \ if (!(_a_)) {\ ERROR_LOG(_t_, "Error...\n\n Line: %d\n File: %s\n Time: %s\n\nIgnore and continue?", \ @@ -102,34 +127,27 @@ extern void __Log(int logNumber, const char* text, ...); } #define _dbg_update_() Host_UpdateLogDisplay(); -#else // no logging -#define LOGLEVEL 1 - +#else // not debug #define _dbg_clear_() #define _dbg_update_() ; #ifndef _dbg_assert_ #define _dbg_assert_(_t_, _a_) ; #define _dbg_assert_msg_(_t_, _a_, _desc_, ...) ; -#endif +#endif // dbg_assert +#endif // LOGLEVEL LDEBUG -#define GENERIC_LOG(t,v, ...) {} -#define ERROR_LOG(t, ...) {} -#define WARN_LOG(t, ...) {} -#define INFO_LOG(t ,...) {} -#define DEBUG_LOG(t, ...) {} - -#endif - -#ifdef _WIN32 #define _assert_(_a_) _dbg_assert_(MASTER_LOG, _a_) -#define _assert_msg_(_t_, _a_, _fmt_, ...)\ +#ifdef _WIN32 +#define _assert_msg_(_t_, _a_, _fmt_, ...) \ if (!(_a_)) {\ if (!PanicYesNo(_fmt_, __VA_ARGS__)) {Crash();} \ } -#else -#define _assert_(a) -#define _assert_msg_(...) -#endif +#else // not win32 +#define _assert_msg_(_t_, _a_, _fmt_, ...) \ + if (!(_a_)) {\ + if (!PanicYesNo(_fmt_, ##__VA_ARGS__)) {Crash();} \ + } +#endif // WIN32 #endif // LOG_H diff --git a/Source/Core/Core/Src/ActionReplay.cpp b/Source/Core/Core/Src/ActionReplay.cpp index 00c6881b1e..1a00cd21be 100644 --- a/Source/Core/Core/Src/ActionReplay.cpp +++ b/Source/Core/Core/Src/ActionReplay.cpp @@ -178,15 +178,15 @@ void LogInfo(const char *format, ...) { if (!b_RanOnce) { - if (LogManager::Enabled() || logSelf) + if (LogManager::GetLevel() >= LogTypes::LINFO || logSelf) { char* temp = (char*)alloca(strlen(format)+512); va_list args; va_start(args, format); CharArrayFromFormatV(temp, 512, format, args); va_end(args); - if (LogManager::Enabled()) - LogManager::Log(LogTypes::ACTIONREPLAY, temp); + INFO_LOG(ACTIONREPLAY, temp); + if (logSelf) { std::string text = temp; diff --git a/Source/Core/Core/Src/Console.cpp b/Source/Core/Core/Src/Console.cpp index 90a5136385..4fabfa9a0c 100644 --- a/Source/Core/Core/Src/Console.cpp +++ b/Source/Core/Core/Src/Console.cpp @@ -53,7 +53,7 @@ void Console_Submit(const char *cmd) if (addr) { -#ifdef LOGGING +#if LOGLEVEL >= 3 u32 EA = #endif Memory::CheckDTLB(addr, Memory::FLAG_NO_EXCEPTION); diff --git a/Source/Core/Core/Src/HW/DVDInterface.cpp b/Source/Core/Core/Src/HW/DVDInterface.cpp index 141a94d1bb..d195e7d8a2 100644 --- a/Source/Core/Core/Src/HW/DVDInterface.cpp +++ b/Source/Core/Core/Src/HW/DVDInterface.cpp @@ -447,7 +447,7 @@ void ExecuteCommand(UDIDMAControlRegister& _DMAControlReg) //========================================================================================================= case 0x12: { -#ifdef LOGGING +#if LOGLEVEL >= 3 u32 offset = dvdMem.Command[1]; // u32 sourcelength = dvdMem.Command[2]; #endif @@ -504,7 +504,7 @@ void ExecuteCommand(UDIDMAControlRegister& _DMAControlReg) //========================================================================================================= case 0xAB: { -#ifdef LOGGING +#if LOGLEVEL >= 4 u32 offset = dvdMem.Command[1] << 2; #endif DEBUG_LOG(DVDINTERFACE, "DVD: Trying to seek: offset=%08x", offset); @@ -537,7 +537,7 @@ void ExecuteCommand(UDIDMAControlRegister& _DMAControlReg) // ugly hack to catch the disable command if (dvdMem.Command[1]!=0) { -#ifdef LOGGING +#if LOGLEVEL >= 4 u8 subCommand = (dvdMem.Command[0] & 0x00FF0000) >> 16; #endif diff --git a/Source/Core/Core/Src/HW/EXI_DeviceIPL.cpp b/Source/Core/Core/Src/HW/EXI_DeviceIPL.cpp index 468e889dc6..dd135db64b 100644 --- a/Source/Core/Core/Src/HW/EXI_DeviceIPL.cpp +++ b/Source/Core/Core/Src/HW/EXI_DeviceIPL.cpp @@ -185,7 +185,7 @@ void CEXIIPL::TransferByte(u8& _uByte) m_RTC[i] = pGCTime[i^3]; } -#ifdef LOGGING +#if LOGLEVEL >= 3 if ((m_uAddress & 0xF0000000) == 0xb0000000) { diff --git a/Source/Core/Core/Src/HW/Memmap.cpp b/Source/Core/Core/Src/HW/Memmap.cpp index 8ae4c0ecc0..6ae5f0c185 100644 --- a/Source/Core/Core/Src/HW/Memmap.cpp +++ b/Source/Core/Core/Src/HW/Memmap.cpp @@ -65,7 +65,7 @@ namespace Memory // #define NOCHECK // Always disable memory checks if the Release build -#ifndef LOGGING +#if LOGLEVEL < 4 #define NOCHECK #endif diff --git a/Source/Core/Core/Src/HW/MemmapFunctions.cpp b/Source/Core/Core/Src/HW/MemmapFunctions.cpp index df6b004a90..1af3c55a36 100644 --- a/Source/Core/Core/Src/HW/MemmapFunctions.cpp +++ b/Source/Core/Core/Src/HW/MemmapFunctions.cpp @@ -237,9 +237,10 @@ void WriteToHardware(u32 em_address, const T data, u32 effective_address, Memory // ---------------- u32 Read_Opcode(const u32 _Address) { -#ifdef LOGGING +#if LOGLEVEL >= 4 if (_Address == 0x00000000) { + // FIXME use assert? PanicAlert("Program tried to read from [00000000]"); return 0x00000000; } @@ -282,13 +283,13 @@ u16 Read_U16(const u32 _Address) u32 Read_U32(const u32 _Address) { -#ifdef LOGGING + /*#if LOGLEVEL >= 4 if (_Address == 0x00000000) { //PanicAlert("Program tried to read from [00000000]"); //return 0x00000000; } -#endif + #endif*/ u32 _var = 0; ReadFromHardware(_var, _Address, _Address, FLAG_READ); #ifndef NOCHECK diff --git a/Source/Core/Core/Src/HW/SI.cpp b/Source/Core/Core/Src/HW/SI.cpp index 621f5b8446..9d30334b6c 100644 --- a/Source/Core/Core/Src/HW/SI.cpp +++ b/Source/Core/Core/Src/HW/SI.cpp @@ -593,7 +593,7 @@ void RunSIBuffer() else outLength++; -#ifdef LOGGING +#if LOGLEVEL >= 3 int numOutput = #endif g_Channel[g_ComCSR.CHANNEL].m_pDevice->RunBuffer(g_SIBuffer, inLength); diff --git a/Source/Core/Core/Src/IPC_HLE/WII_IPC_HLE_Device_net.h b/Source/Core/Core/Src/IPC_HLE/WII_IPC_HLE_Device_net.h index c984aa4845..501b08d451 100644 --- a/Source/Core/Core/Src/IPC_HLE/WII_IPC_HLE_Device_net.h +++ b/Source/Core/Core/Src/IPC_HLE/WII_IPC_HLE_Device_net.h @@ -66,7 +66,7 @@ public: virtual bool IOCtl(u32 _CommandAddress) { - #ifdef LOGGING + #if LOGLEVEL >= 4 u32 Parameter = Memory::Read_U32(_CommandAddress +0x0C); u32 Buffer1 = Memory::Read_U32(_CommandAddress +0x10); u32 BufferSize1 = Memory::Read_U32(_CommandAddress +0x14); @@ -77,7 +77,7 @@ public: // write return value Memory::Write_U32(0, _CommandAddress + 0x4); - INFO_LOG(WII_IPC_NET, "%s - IOCtl:\n" + DEBUG_LOG(WII_IPC_NET, "%s - IOCtl:\n" " Parameter: 0x%x (0x17 could be some kind of Sync RTC) \n" " Buffer1: 0x%08x\n" " BufferSize1: 0x%08x\n" diff --git a/Source/Core/Core/Src/IPC_HLE/WII_IPC_HLE_Device_usb.cpp b/Source/Core/Core/Src/IPC_HLE/WII_IPC_HLE_Device_usb.cpp index c909eaca3f..ff55716a7f 100644 --- a/Source/Core/Core/Src/IPC_HLE/WII_IPC_HLE_Device_usb.cpp +++ b/Source/Core/Core/Src/IPC_HLE/WII_IPC_HLE_Device_usb.cpp @@ -613,7 +613,7 @@ bool CWII_IPC_HLE_Device_usb_oh1_57e_305::SendEventRequestConnection(CWII_IPC_HL AddEventToQueue(Event); // Log -#ifdef LOGGING +#if LOGLEVEL >= 4 static char LinkType[][128] = { { "HCI_LINK_SCO 0x00 - Voice"}, @@ -718,7 +718,7 @@ bool CWII_IPC_HLE_Device_usb_oh1_57e_305::SendEventConnectionComplete(bdaddr_t _ g_GlobalHandle = pConnectionComplete->Connection_Handle; -#ifdef LOGGING +#if LOGLEVEL >= 4 static char s_szLinkType[][128] = { { "HCI_LINK_SCO 0x00 - Voice"}, @@ -1412,7 +1412,7 @@ void CWII_IPC_HLE_Device_usb_oh1_57e_305::CommandHostBufferSize(u8* _Input) // ---------------- void CWII_IPC_HLE_Device_usb_oh1_57e_305::CommandWritePageTimeOut(u8* _Input) { -#ifdef LOGGING +#if LOGLEVEL >= 4 // command parameters hci_write_page_timeout_cp* pWritePageTimeOut = (hci_write_page_timeout_cp*)_Input; #endif @@ -1442,7 +1442,7 @@ void CWII_IPC_HLE_Device_usb_oh1_57e_305::CommandWriteScanEnable(u8* _Input) hci_write_scan_enable_rp Reply; Reply.status = 0x00; -#ifdef LOGGING +#if LOGLEVEL >= 4 static char Scanning[][128] = { { "HCI_NO_SCAN_ENABLE"}, @@ -1463,7 +1463,7 @@ void CWII_IPC_HLE_Device_usb_oh1_57e_305::CommandWriteScanEnable(u8* _Input) void CWII_IPC_HLE_Device_usb_oh1_57e_305::CommandWriteInquiryMode(u8* _Input) { -#ifdef LOGGING +#if LOGLEVEL >= 4 // command parameters hci_write_inquiry_mode_cp* pInquiryMode = (hci_write_inquiry_mode_cp*)_Input; #endif @@ -1472,7 +1472,7 @@ void CWII_IPC_HLE_Device_usb_oh1_57e_305::CommandWriteInquiryMode(u8* _Input) hci_write_inquiry_mode_rp Reply; Reply.status = 0x00; -#ifdef LOGGING +#if LOGLEVEL >= 4 static char InquiryMode[][128] = { { "Standard Inquiry Result event format (default)" }, @@ -1489,7 +1489,7 @@ void CWII_IPC_HLE_Device_usb_oh1_57e_305::CommandWriteInquiryMode(u8* _Input) void CWII_IPC_HLE_Device_usb_oh1_57e_305::CommandWritePageScanType(u8* _Input) { -#ifdef LOGGING +#if LOGLEVEL >= 4 // command parameters hci_write_page_scan_type_cp* pWritePageScanType = (hci_write_page_scan_type_cp*)_Input; #endif @@ -1498,7 +1498,7 @@ void CWII_IPC_HLE_Device_usb_oh1_57e_305::CommandWritePageScanType(u8* _Input) hci_write_page_scan_type_rp Reply; Reply.status = 0x00; -#ifdef LOGGING +#if LOGLEVEL >= 4 static char PageScanType[][128] = { { "Mandatory: Standard Scan (default)" }, @@ -1555,7 +1555,7 @@ void CWII_IPC_HLE_Device_usb_oh1_57e_305::CommandInquiry(u8* _Input) void CWII_IPC_HLE_Device_usb_oh1_57e_305::CommandWriteInquiryScanType(u8* _Input) { -#ifdef LOGGING +#if LOGLEVEL >= 4 // command parameters hci_write_inquiry_scan_type_cp* pSetEventFilter = (hci_write_inquiry_scan_type_cp*)_Input; #endif @@ -1659,7 +1659,7 @@ void CWII_IPC_HLE_Device_usb_oh1_57e_305::CommandAcceptCon(u8* _Input) // command parameters hci_accept_con_cp* pAcceptCon = (hci_accept_con_cp*)_Input; -#ifdef LOGGING +#if LOGLEVEL >= 4 static char s_szRole[][128] = { { "Master (0x00)"}, diff --git a/Source/Core/Core/Src/LogManager.cpp b/Source/Core/Core/Src/LogManager.cpp index 9ec297808b..83b3ed554c 100644 --- a/Source/Core/Core/Src/LogManager.cpp +++ b/Source/Core/Core/Src/LogManager.cpp @@ -94,14 +94,14 @@ CDebugger_LogSettings::~CDebugger_LogSettings(void) {} void CDebugger_Log::Init() { -#ifdef LOGGING +#if LOGLEVEL > 0 m_pFile = fopen(m_szFilename, "wtb"); #endif } void CDebugger_Log::Shutdown() { -#ifdef LOGGING +#if LOGLEVEL > 0 if (m_pFile != NULL) { fclose(m_pFile); diff --git a/Source/Core/Core/Src/LogManager.h b/Source/Core/Core/Src/LogManager.h index 2ab35ba02a..70efe865b2 100644 --- a/Source/Core/Core/Src/LogManager.h +++ b/Source/Core/Core/Src/LogManager.h @@ -101,7 +101,7 @@ public: private: enum LOG_SETTINGS { - VERBOSITY_LEVELS = 3 + VERBOSITY_LEVELS = LOGLEVEL }; friend class CDebugger_LogWindow; @@ -118,11 +118,7 @@ public: static void Init(); static void Clear(void); static void Shutdown(); -#ifdef LOGGING - static bool Enabled() { return true; } -#else - static bool Enabled() { return false; } -#endif + static int GetLevel() {return LOGLEVEL;} static void Log(LogTypes::LOG_TYPE _type, const char *_fmt, ...); }; diff --git a/Source/Core/DebuggerWX/Src/CodeWindow.cpp b/Source/Core/DebuggerWX/Src/CodeWindow.cpp index 0c4f96e029..868031e18e 100644 --- a/Source/Core/DebuggerWX/Src/CodeWindow.cpp +++ b/Source/Core/DebuggerWX/Src/CodeWindow.cpp @@ -376,7 +376,7 @@ void CCodeWindow::CreateGUIControls(const SCoreStartupParameter& _LocalCoreStart // Additional dialogs -#ifdef LOGGING +#if LOGLEVEL > 0 if (bLogWindow) { m_LogWindow = new CLogWindow(this); @@ -504,7 +504,7 @@ void CCodeWindow::CreateMenu(const SCoreStartupParameter& _LocalCoreStartupParam // --------------- wxMenu* pDebugDialogs = new wxMenu; - if (LogManager::Enabled()) + if (LogManager::GetLevel() > 0) { wxMenuItem* pLogWindow = pDebugDialogs->Append(IDM_LOGWINDOW, _T("&LogManager"), wxEmptyString, wxITEM_CHECK); pLogWindow->Check(bLogWindow); diff --git a/Source/Core/DebuggerWX/Src/CodeWindowSJP.cpp b/Source/Core/DebuggerWX/Src/CodeWindowSJP.cpp index 75f10818ae..0beaa10a25 100644 --- a/Source/Core/DebuggerWX/Src/CodeWindowSJP.cpp +++ b/Source/Core/DebuggerWX/Src/CodeWindowSJP.cpp @@ -316,7 +316,7 @@ void CCodeWindow::OnSymbolListContextMenu(wxContextMenuEvent& event) ///////////////////////////////////////////////////////////////////////////////////////////////// void CCodeWindow::OnToggleLogWindow(wxCommandEvent& event) { - if (LogManager::Enabled()) + if (LogManager::GetLevel() > 0) { bool show = GetMenuBar()->IsChecked(event.GetId()); diff --git a/Source/Core/DebuggerWX/Src/LogWindow.cpp b/Source/Core/DebuggerWX/Src/LogWindow.cpp index d6e6e2a10b..93772937d6 100644 --- a/Source/Core/DebuggerWX/Src/LogWindow.cpp +++ b/Source/Core/DebuggerWX/Src/LogWindow.cpp @@ -50,7 +50,11 @@ CLogWindow::CLogWindow(wxWindow* parent) // left checkboxes and radio boxes ----------------------------------- int m_radioBoxNChoices[1]; - wxString m_radioBoxChoices0[] = { wxT("0"), wxT("1"), wxT("2"), wxT("3") }; + wxString m_radioBoxChoices0[LOGLEVEL+1]; + for (int i=0;i<=LOGLEVEL;i++) { + m_radioBoxChoices0[i] = wxString::Format(wxT("%d"), i); + } + m_radioBoxNChoices[0] = sizeof( m_radioBoxChoices0 ) / sizeof( wxString ); m_RadioBox[0] = new wxRadioBox( this, IDM_RADIO0, wxT("Verbosity"), wxDefaultPosition, wxDefaultSize, m_radioBoxNChoices[0], m_radioBoxChoices0, 1, wxRA_SPECIFY_ROWS); diff --git a/Source/Core/DolphinWX/Src/Main.cpp b/Source/Core/DolphinWX/Src/Main.cpp index 73c487a55e..ee9ed2de4e 100644 --- a/Source/Core/DolphinWX/Src/Main.cpp +++ b/Source/Core/DolphinWX/Src/Main.cpp @@ -267,7 +267,7 @@ bool DolphinApp::OnInit() } if(!UseDebugger && UseLogger) { - #ifdef LOGGING + #if LOGLEVEL > 0 // We aren't using debugger, just logger // Should be fine for a local copy CLogWindow* m_LogWindow = new CLogWindow(main_frame); diff --git a/Source/Core/VideoCommon/Src/VideoCommon.h b/Source/Core/VideoCommon/Src/VideoCommon.h index 38b9082927..8082da16b5 100644 --- a/Source/Core/VideoCommon/Src/VideoCommon.h +++ b/Source/Core/VideoCommon/Src/VideoCommon.h @@ -113,10 +113,7 @@ void HandleGLError(); #define PRIM_LOG(...) {DEBUG_LOG(VIDEO, ##__VA_ARGS__)} #endif -#ifdef LOGGING -#define LOG_VTX() PRIM_LOG("vtx: %f %f %f, ", ((float*)VertexManager::s_pCurBufferPointer)[0], ((float*)VertexManager::s_pCurBufferPointer)[1], ((float*)VertexManager::s_pCurBufferPointer)[2]); -#else -#define LOG_VTX() -#endif +#define LOG_VTX() DEBUG_LOG(VIDEO, "vtx: %f %f %f, ", ((float*)VertexManager::s_pCurBufferPointer)[0], ((float*)VertexManager::s_pCurBufferPointer)[1], ((float*)VertexManager::s_pCurBufferPointer)[2]); + #endif // _VIDEOCOMMON_H diff --git a/Source/Plugins/Plugin_VideoOGL/Src/Globals.cpp b/Source/Plugins/Plugin_VideoOGL/Src/Globals.cpp index b2546885a4..43e82bc6f3 100644 --- a/Source/Plugins/Plugin_VideoOGL/Src/Globals.cpp +++ b/Source/Plugins/Plugin_VideoOGL/Src/Globals.cpp @@ -60,7 +60,7 @@ static FILE* pfLog = NULL; // This is on by default, but can be controlled from the debugging window bool LocalLogFile = true; -#ifdef LOGGING +#if LOGLEVEL > 0 void __Log(const char *fmt, ...) { int len = strlen(fmt);