2009-09-08 12:08:10 +00:00
|
|
|
/* PCSX2 - PS2 Emulator for PCs
|
2010-05-03 14:08:02 +00:00
|
|
|
* Copyright (C) 2002-2010 PCSX2 Dev Team
|
2009-11-08 04:32:15 +00:00
|
|
|
*
|
2009-09-08 12:08:10 +00:00
|
|
|
* PCSX2 is free software: you can redistribute it and/or modify it under the terms
|
|
|
|
* of the GNU Lesser General Public License as published by the Free Software Found-
|
|
|
|
* ation, either version 3 of the License, or (at your option) any later version.
|
2009-07-03 00:49:40 +00:00
|
|
|
*
|
2009-09-08 12:08:10 +00:00
|
|
|
* PCSX2 is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
|
|
|
|
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
|
|
|
* PURPOSE. See the GNU General Public License for more details.
|
2009-07-03 00:49:40 +00:00
|
|
|
*
|
2009-09-08 12:08:10 +00:00
|
|
|
* You should have received a copy of the GNU General Public License along with PCSX2.
|
|
|
|
* If not, see <http://www.gnu.org/licenses/>.
|
2009-07-03 00:49:40 +00:00
|
|
|
*/
|
|
|
|
|
2021-09-01 20:31:46 +00:00
|
|
|
#include "common/Threading.h"
|
|
|
|
#include "common/TraceLog.h"
|
|
|
|
#include "common/RedtapeWindows.h" // OutputDebugString
|
2010-06-06 04:17:43 +00:00
|
|
|
|
2009-07-03 00:49:40 +00:00
|
|
|
using namespace Threading;
|
|
|
|
|
2009-12-24 22:22:34 +00:00
|
|
|
// thread-local console indentation setting.
|
2022-05-09 10:37:53 +00:00
|
|
|
static thread_local int conlog_Indent(0);
|
2009-12-24 22:22:34 +00:00
|
|
|
|
|
|
|
// thread-local console color storage.
|
2022-05-09 10:37:53 +00:00
|
|
|
static thread_local ConsoleColors conlog_Color(DefaultConsoleColor);
|
2009-12-24 22:22:34 +00:00
|
|
|
|
2015-11-17 17:38:26 +00:00
|
|
|
#ifdef __POSIX__
|
2021-09-11 03:11:54 +00:00
|
|
|
#include <unistd.h>
|
|
|
|
|
2021-09-06 18:28:26 +00:00
|
|
|
static FILE* stdout_fp = stdout;
|
2015-10-31 00:16:17 +00:00
|
|
|
|
2021-09-11 03:11:54 +00:00
|
|
|
static bool checkSupportsColor()
|
|
|
|
{
|
|
|
|
if (!isatty(fileno(stdout_fp)))
|
|
|
|
return false;
|
|
|
|
char* term = getenv("TERM");
|
|
|
|
if (!term || (0 == strcmp(term, "dumb")))
|
|
|
|
return false;
|
|
|
|
return true; // Probably supports color
|
|
|
|
}
|
|
|
|
|
|
|
|
static bool supports_color = checkSupportsColor();
|
|
|
|
|
2021-09-06 18:28:26 +00:00
|
|
|
void Console_SetStdout(FILE* fp)
|
2015-10-31 00:16:17 +00:00
|
|
|
{
|
2021-09-06 18:28:26 +00:00
|
|
|
stdout_fp = fp;
|
2015-10-31 00:16:17 +00:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2009-10-05 14:40:46 +00:00
|
|
|
// This function re-assigns the console log writer(s) to the specified target. It makes sure
|
|
|
|
// to flush any contents from the buffered console log (which typically accumulates due to
|
|
|
|
// log suspension during log file/window re-init operations) into the new log.
|
|
|
|
//
|
|
|
|
// Important! Only Assert and Null console loggers are allowed during C++ startup init (when
|
|
|
|
// the program or DLL first loads). Other log targets rely on the static buffer and a
|
|
|
|
// threaded mutex lock, which are only valid after C++ initialization has finished.
|
2021-09-06 18:28:26 +00:00
|
|
|
void Console_SetActiveHandler(const IConsoleWriter& writer, FILE* flushfp)
|
2009-07-03 00:49:40 +00:00
|
|
|
{
|
2021-09-06 18:28:26 +00:00
|
|
|
pxAssertDev(
|
|
|
|
(writer.WriteRaw != NULL) && (writer.DoWriteLn != NULL) &&
|
|
|
|
(writer.Newline != NULL) && (writer.SetTitle != NULL) &&
|
|
|
|
(writer.DoSetColor != NULL),
|
|
|
|
"Invalid IConsoleWriter object! All function pointer interfaces must be implemented.");
|
2009-11-08 04:32:15 +00:00
|
|
|
|
2021-09-06 18:28:26 +00:00
|
|
|
Console = writer;
|
|
|
|
DevConWriter = writer;
|
2009-07-03 00:49:40 +00:00
|
|
|
|
Lots of new code maintenance stuffs:
* Completely new assertion macros: pxAssert, pxAssertMsg, and pxFail, pxAssertDev (both which default to using a message). These replace *all* wxASSERT, DevAssert, and jASSUME varieties of macros. New macros borrow the best of all assertion worlds: MSVCRT, wxASSERT, and AtlAssume. :)
* Rewrote the Console namespace as a structure called IConsoleWriter, and created several varieties of ConsoleWriters for handling different states of log and console availability (should help reduce overhead of console logging nicely).
* More improvements to the PersistentThread model, using safely interlocked "Do*" style callbacks for starting and cleaning up threads.
* Fixed console logs so that they're readable in Win32 notepad again (the log writer adds CRs to naked LFs).
* Added AppInit.cpp -- contains constructor, destructor, OnInit, and command line parsing mess.
git-svn-id: http://pcsx2.googlecode.com/svn/trunk@1950 96395faa-99c1-11dd-bbfe-3dabce05a288
2009-10-04 08:27:27 +00:00
|
|
|
#ifdef PCSX2_DEBUG
|
2021-09-06 18:28:26 +00:00
|
|
|
DbgCon = writer;
|
2010-08-06 05:46:09 +00:00
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
// Writes text to the Visual Studio Output window (Microsoft Windows only).
|
|
|
|
// On all other platforms this pipes to Stdout instead.
|
2021-09-06 18:28:26 +00:00
|
|
|
void MSW_OutputDebugString(const wxString& text)
|
2010-08-06 05:46:09 +00:00
|
|
|
{
|
|
|
|
#if defined(__WXMSW__) && !defined(__WXMICROWIN__)
|
2021-09-06 18:28:26 +00:00
|
|
|
static bool hasDebugger = wxIsDebuggerRunning();
|
|
|
|
if (hasDebugger)
|
|
|
|
OutputDebugString(text);
|
2010-08-06 05:46:09 +00:00
|
|
|
#else
|
2021-09-06 18:28:26 +00:00
|
|
|
fputs(text.utf8_str(), stdout_fp);
|
|
|
|
fflush(stdout_fp);
|
Lots of new code maintenance stuffs:
* Completely new assertion macros: pxAssert, pxAssertMsg, and pxFail, pxAssertDev (both which default to using a message). These replace *all* wxASSERT, DevAssert, and jASSUME varieties of macros. New macros borrow the best of all assertion worlds: MSVCRT, wxASSERT, and AtlAssume. :)
* Rewrote the Console namespace as a structure called IConsoleWriter, and created several varieties of ConsoleWriters for handling different states of log and console availability (should help reduce overhead of console logging nicely).
* More improvements to the PersistentThread model, using safely interlocked "Do*" style callbacks for starting and cleaning up threads.
* Fixed console logs so that they're readable in Win32 notepad again (the log writer adds CRs to naked LFs).
* Added AppInit.cpp -- contains constructor, destructor, OnInit, and command line parsing mess.
git-svn-id: http://pcsx2.googlecode.com/svn/trunk@1950 96395faa-99c1-11dd-bbfe-3dabce05a288
2009-10-04 08:27:27 +00:00
|
|
|
#endif
|
|
|
|
}
|
2009-07-03 00:49:40 +00:00
|
|
|
|
2015-10-31 00:16:17 +00:00
|
|
|
|
Lots of new code maintenance stuffs:
* Completely new assertion macros: pxAssert, pxAssertMsg, and pxFail, pxAssertDev (both which default to using a message). These replace *all* wxASSERT, DevAssert, and jASSUME varieties of macros. New macros borrow the best of all assertion worlds: MSVCRT, wxASSERT, and AtlAssume. :)
* Rewrote the Console namespace as a structure called IConsoleWriter, and created several varieties of ConsoleWriters for handling different states of log and console availability (should help reduce overhead of console logging nicely).
* More improvements to the PersistentThread model, using safely interlocked "Do*" style callbacks for starting and cleaning up threads.
* Fixed console logs so that they're readable in Win32 notepad again (the log writer adds CRs to naked LFs).
* Added AppInit.cpp -- contains constructor, destructor, OnInit, and command line parsing mess.
git-svn-id: http://pcsx2.googlecode.com/svn/trunk@1950 96395faa-99c1-11dd-bbfe-3dabce05a288
2009-10-04 08:27:27 +00:00
|
|
|
// --------------------------------------------------------------------------------------
|
2009-10-05 14:40:46 +00:00
|
|
|
// ConsoleNull
|
Lots of new code maintenance stuffs:
* Completely new assertion macros: pxAssert, pxAssertMsg, and pxFail, pxAssertDev (both which default to using a message). These replace *all* wxASSERT, DevAssert, and jASSUME varieties of macros. New macros borrow the best of all assertion worlds: MSVCRT, wxASSERT, and AtlAssume. :)
* Rewrote the Console namespace as a structure called IConsoleWriter, and created several varieties of ConsoleWriters for handling different states of log and console availability (should help reduce overhead of console logging nicely).
* More improvements to the PersistentThread model, using safely interlocked "Do*" style callbacks for starting and cleaning up threads.
* Fixed console logs so that they're readable in Win32 notepad again (the log writer adds CRs to naked LFs).
* Added AppInit.cpp -- contains constructor, destructor, OnInit, and command line parsing mess.
git-svn-id: http://pcsx2.googlecode.com/svn/trunk@1950 96395faa-99c1-11dd-bbfe-3dabce05a288
2009-10-04 08:27:27 +00:00
|
|
|
// --------------------------------------------------------------------------------------
|
2009-07-03 00:49:40 +00:00
|
|
|
|
2022-05-12 12:34:42 +00:00
|
|
|
static void ConsoleNull_SetTitle(const wxString& title) {}
|
|
|
|
static void ConsoleNull_DoSetColor(ConsoleColors color) {}
|
|
|
|
static void ConsoleNull_Newline() {}
|
|
|
|
static void ConsoleNull_DoWrite(const wxString& fmt) {}
|
|
|
|
static void ConsoleNull_DoWriteLn(const wxString& fmt) {}
|
2009-07-03 00:49:40 +00:00
|
|
|
|
2009-10-05 14:40:46 +00:00
|
|
|
const IConsoleWriter ConsoleWriter_Null =
|
2021-09-06 18:28:26 +00:00
|
|
|
{
|
|
|
|
ConsoleNull_DoWrite,
|
|
|
|
ConsoleNull_DoWriteLn,
|
|
|
|
ConsoleNull_DoSetColor,
|
2009-10-05 14:40:46 +00:00
|
|
|
|
2021-09-06 18:28:26 +00:00
|
|
|
ConsoleNull_DoWrite,
|
|
|
|
ConsoleNull_Newline,
|
|
|
|
ConsoleNull_SetTitle,
|
2009-11-18 16:53:44 +00:00
|
|
|
|
2021-09-06 18:28:26 +00:00
|
|
|
0, // instance-level indentation (should always be 0)
|
2009-10-05 14:40:46 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
// --------------------------------------------------------------------------------------
|
2009-12-07 22:43:16 +00:00
|
|
|
// Console_Stdout
|
2009-10-05 14:40:46 +00:00
|
|
|
// --------------------------------------------------------------------------------------
|
|
|
|
|
2021-09-11 01:09:01 +00:00
|
|
|
#if defined(__POSIX__)
|
2021-09-06 18:28:26 +00:00
|
|
|
static __fi const char* GetLinuxConsoleColor(ConsoleColors color)
|
|
|
|
{
|
|
|
|
switch (color)
|
|
|
|
{
|
|
|
|
case Color_Black:
|
|
|
|
case Color_StrongBlack:
|
|
|
|
return "\033[30m\033[1m";
|
|
|
|
|
|
|
|
case Color_Red:
|
|
|
|
return "\033[31m";
|
|
|
|
case Color_StrongRed:
|
|
|
|
return "\033[31m\033[1m";
|
|
|
|
|
|
|
|
case Color_Green:
|
|
|
|
return "\033[32m";
|
|
|
|
case Color_StrongGreen:
|
|
|
|
return "\033[32m\033[1m";
|
|
|
|
|
|
|
|
case Color_Yellow:
|
|
|
|
return "\033[33m";
|
|
|
|
case Color_StrongYellow:
|
|
|
|
return "\033[33m\033[1m";
|
|
|
|
|
|
|
|
case Color_Blue:
|
|
|
|
return "\033[34m";
|
|
|
|
case Color_StrongBlue:
|
|
|
|
return "\033[34m\033[1m";
|
|
|
|
|
|
|
|
// No orange, so use magenta.
|
|
|
|
case Color_Orange:
|
|
|
|
case Color_Magenta:
|
|
|
|
return "\033[35m";
|
|
|
|
case Color_StrongOrange:
|
|
|
|
case Color_StrongMagenta:
|
|
|
|
return "\033[35m\033[1m";
|
|
|
|
|
|
|
|
case Color_Cyan:
|
|
|
|
return "\033[36m";
|
|
|
|
case Color_StrongCyan:
|
|
|
|
return "\033[36m\033[1m";
|
|
|
|
|
|
|
|
// Use 'white' instead of grey.
|
|
|
|
case Color_Gray:
|
|
|
|
case Color_White:
|
|
|
|
return "\033[37m";
|
|
|
|
case Color_StrongGray:
|
|
|
|
case Color_StrongWhite:
|
|
|
|
return "\033[37m\033[1m";
|
|
|
|
|
|
|
|
// On some other value being passed, clear any formatting.
|
|
|
|
case Color_Default:
|
|
|
|
default:
|
|
|
|
return "\033[0m";
|
|
|
|
}
|
2009-11-12 14:52:29 +00:00
|
|
|
}
|
2009-11-08 04:32:15 +00:00
|
|
|
#endif
|
|
|
|
|
2009-10-05 14:40:46 +00:00
|
|
|
// One possible default write action at startup and shutdown is to use the stdout.
|
2022-05-12 12:34:42 +00:00
|
|
|
static void ConsoleStdout_DoWrite(const wxString& fmt)
|
2009-10-05 14:40:46 +00:00
|
|
|
{
|
2021-09-06 18:28:26 +00:00
|
|
|
MSW_OutputDebugString(fmt);
|
2009-10-05 14:40:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Default write action at startup and shutdown is to use the stdout.
|
2022-05-12 12:34:42 +00:00
|
|
|
static void ConsoleStdout_DoWriteLn(const wxString& fmt)
|
2009-10-05 14:40:46 +00:00
|
|
|
{
|
2021-09-06 18:28:26 +00:00
|
|
|
MSW_OutputDebugString(fmt + L"\n");
|
2009-10-05 14:40:46 +00:00
|
|
|
}
|
|
|
|
|
2022-05-12 12:34:42 +00:00
|
|
|
static void ConsoleStdout_Newline()
|
2009-11-08 04:32:15 +00:00
|
|
|
{
|
2021-09-06 18:28:26 +00:00
|
|
|
MSW_OutputDebugString(L"\n");
|
2009-11-08 04:32:15 +00:00
|
|
|
}
|
|
|
|
|
2022-05-12 12:34:42 +00:00
|
|
|
static void ConsoleStdout_DoSetColor(ConsoleColors color)
|
2009-11-08 04:32:15 +00:00
|
|
|
{
|
2021-09-11 01:09:01 +00:00
|
|
|
#if defined(__POSIX__)
|
2021-09-11 03:11:54 +00:00
|
|
|
if (!supports_color)
|
|
|
|
return;
|
2021-09-06 18:28:26 +00:00
|
|
|
fprintf(stdout_fp, "\033[0m%s", GetLinuxConsoleColor(color));
|
|
|
|
fflush(stdout_fp);
|
2009-11-08 04:32:15 +00:00
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2022-05-12 12:34:42 +00:00
|
|
|
static void ConsoleStdout_SetTitle(const wxString& title)
|
2009-11-08 04:32:15 +00:00
|
|
|
{
|
2021-09-11 01:09:01 +00:00
|
|
|
#if defined(__POSIX__)
|
2021-09-11 03:11:54 +00:00
|
|
|
if (supports_color)
|
|
|
|
fputs("\033]0;", stdout_fp);
|
2021-09-06 18:28:26 +00:00
|
|
|
fputs(title.utf8_str(), stdout_fp);
|
2021-09-11 03:11:54 +00:00
|
|
|
if (supports_color)
|
|
|
|
fputs("\007", stdout_fp);
|
2009-11-08 04:32:15 +00:00
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2009-12-07 22:43:16 +00:00
|
|
|
const IConsoleWriter ConsoleWriter_Stdout =
|
2021-09-06 18:28:26 +00:00
|
|
|
{
|
|
|
|
ConsoleStdout_DoWrite, // Writes without newlines go to buffer to avoid error log spam.
|
|
|
|
ConsoleStdout_DoWriteLn,
|
|
|
|
ConsoleStdout_DoSetColor,
|
|
|
|
|
|
|
|
ConsoleNull_DoWrite, // writes from re-piped stdout are ignored here, lest we create infinite loop hell >_<
|
|
|
|
ConsoleStdout_Newline,
|
|
|
|
ConsoleStdout_SetTitle,
|
|
|
|
0, // instance-level indentation (should always be 0)
|
2009-10-05 14:40:46 +00:00
|
|
|
};
|
|
|
|
|
Lots of new code maintenance stuffs:
* Completely new assertion macros: pxAssert, pxAssertMsg, and pxFail, pxAssertDev (both which default to using a message). These replace *all* wxASSERT, DevAssert, and jASSUME varieties of macros. New macros borrow the best of all assertion worlds: MSVCRT, wxASSERT, and AtlAssume. :)
* Rewrote the Console namespace as a structure called IConsoleWriter, and created several varieties of ConsoleWriters for handling different states of log and console availability (should help reduce overhead of console logging nicely).
* More improvements to the PersistentThread model, using safely interlocked "Do*" style callbacks for starting and cleaning up threads.
* Fixed console logs so that they're readable in Win32 notepad again (the log writer adds CRs to naked LFs).
* Added AppInit.cpp -- contains constructor, destructor, OnInit, and command line parsing mess.
git-svn-id: http://pcsx2.googlecode.com/svn/trunk@1950 96395faa-99c1-11dd-bbfe-3dabce05a288
2009-10-04 08:27:27 +00:00
|
|
|
// --------------------------------------------------------------------------------------
|
2009-10-05 14:40:46 +00:00
|
|
|
// ConsoleAssert
|
Lots of new code maintenance stuffs:
* Completely new assertion macros: pxAssert, pxAssertMsg, and pxFail, pxAssertDev (both which default to using a message). These replace *all* wxASSERT, DevAssert, and jASSUME varieties of macros. New macros borrow the best of all assertion worlds: MSVCRT, wxASSERT, and AtlAssume. :)
* Rewrote the Console namespace as a structure called IConsoleWriter, and created several varieties of ConsoleWriters for handling different states of log and console availability (should help reduce overhead of console logging nicely).
* More improvements to the PersistentThread model, using safely interlocked "Do*" style callbacks for starting and cleaning up threads.
* Fixed console logs so that they're readable in Win32 notepad again (the log writer adds CRs to naked LFs).
* Added AppInit.cpp -- contains constructor, destructor, OnInit, and command line parsing mess.
git-svn-id: http://pcsx2.googlecode.com/svn/trunk@1950 96395faa-99c1-11dd-bbfe-3dabce05a288
2009-10-04 08:27:27 +00:00
|
|
|
// --------------------------------------------------------------------------------------
|
2009-07-03 20:12:33 +00:00
|
|
|
|
2022-05-12 12:34:42 +00:00
|
|
|
static void ConsoleAssert_DoWrite(const wxString& fmt)
|
Lots of new code maintenance stuffs:
* Completely new assertion macros: pxAssert, pxAssertMsg, and pxFail, pxAssertDev (both which default to using a message). These replace *all* wxASSERT, DevAssert, and jASSUME varieties of macros. New macros borrow the best of all assertion worlds: MSVCRT, wxASSERT, and AtlAssume. :)
* Rewrote the Console namespace as a structure called IConsoleWriter, and created several varieties of ConsoleWriters for handling different states of log and console availability (should help reduce overhead of console logging nicely).
* More improvements to the PersistentThread model, using safely interlocked "Do*" style callbacks for starting and cleaning up threads.
* Fixed console logs so that they're readable in Win32 notepad again (the log writer adds CRs to naked LFs).
* Added AppInit.cpp -- contains constructor, destructor, OnInit, and command line parsing mess.
git-svn-id: http://pcsx2.googlecode.com/svn/trunk@1950 96395faa-99c1-11dd-bbfe-3dabce05a288
2009-10-04 08:27:27 +00:00
|
|
|
{
|
2021-09-06 18:28:26 +00:00
|
|
|
pxFail(L"Console class has not been initialized; Message written:\n\t" + fmt);
|
Lots of new code maintenance stuffs:
* Completely new assertion macros: pxAssert, pxAssertMsg, and pxFail, pxAssertDev (both which default to using a message). These replace *all* wxASSERT, DevAssert, and jASSUME varieties of macros. New macros borrow the best of all assertion worlds: MSVCRT, wxASSERT, and AtlAssume. :)
* Rewrote the Console namespace as a structure called IConsoleWriter, and created several varieties of ConsoleWriters for handling different states of log and console availability (should help reduce overhead of console logging nicely).
* More improvements to the PersistentThread model, using safely interlocked "Do*" style callbacks for starting and cleaning up threads.
* Fixed console logs so that they're readable in Win32 notepad again (the log writer adds CRs to naked LFs).
* Added AppInit.cpp -- contains constructor, destructor, OnInit, and command line parsing mess.
git-svn-id: http://pcsx2.googlecode.com/svn/trunk@1950 96395faa-99c1-11dd-bbfe-3dabce05a288
2009-10-04 08:27:27 +00:00
|
|
|
}
|
2009-07-03 00:49:40 +00:00
|
|
|
|
2022-05-12 12:34:42 +00:00
|
|
|
static void ConsoleAssert_DoWriteLn(const wxString& fmt)
|
Lots of new code maintenance stuffs:
* Completely new assertion macros: pxAssert, pxAssertMsg, and pxFail, pxAssertDev (both which default to using a message). These replace *all* wxASSERT, DevAssert, and jASSUME varieties of macros. New macros borrow the best of all assertion worlds: MSVCRT, wxASSERT, and AtlAssume. :)
* Rewrote the Console namespace as a structure called IConsoleWriter, and created several varieties of ConsoleWriters for handling different states of log and console availability (should help reduce overhead of console logging nicely).
* More improvements to the PersistentThread model, using safely interlocked "Do*" style callbacks for starting and cleaning up threads.
* Fixed console logs so that they're readable in Win32 notepad again (the log writer adds CRs to naked LFs).
* Added AppInit.cpp -- contains constructor, destructor, OnInit, and command line parsing mess.
git-svn-id: http://pcsx2.googlecode.com/svn/trunk@1950 96395faa-99c1-11dd-bbfe-3dabce05a288
2009-10-04 08:27:27 +00:00
|
|
|
{
|
2021-09-06 18:28:26 +00:00
|
|
|
pxFail(L"Console class has not been initialized; Message written:\n\t" + fmt);
|
Lots of new code maintenance stuffs:
* Completely new assertion macros: pxAssert, pxAssertMsg, and pxFail, pxAssertDev (both which default to using a message). These replace *all* wxASSERT, DevAssert, and jASSUME varieties of macros. New macros borrow the best of all assertion worlds: MSVCRT, wxASSERT, and AtlAssume. :)
* Rewrote the Console namespace as a structure called IConsoleWriter, and created several varieties of ConsoleWriters for handling different states of log and console availability (should help reduce overhead of console logging nicely).
* More improvements to the PersistentThread model, using safely interlocked "Do*" style callbacks for starting and cleaning up threads.
* Fixed console logs so that they're readable in Win32 notepad again (the log writer adds CRs to naked LFs).
* Added AppInit.cpp -- contains constructor, destructor, OnInit, and command line parsing mess.
git-svn-id: http://pcsx2.googlecode.com/svn/trunk@1950 96395faa-99c1-11dd-bbfe-3dabce05a288
2009-10-04 08:27:27 +00:00
|
|
|
}
|
2009-07-03 00:49:40 +00:00
|
|
|
|
2009-10-05 14:40:46 +00:00
|
|
|
const IConsoleWriter ConsoleWriter_Assert =
|
2021-09-06 18:28:26 +00:00
|
|
|
{
|
|
|
|
ConsoleAssert_DoWrite,
|
|
|
|
ConsoleAssert_DoWriteLn,
|
|
|
|
ConsoleNull_DoSetColor,
|
2009-10-05 14:40:46 +00:00
|
|
|
|
2021-09-06 18:28:26 +00:00
|
|
|
ConsoleNull_DoWrite,
|
|
|
|
ConsoleNull_Newline,
|
|
|
|
ConsoleNull_SetTitle,
|
2009-11-18 16:53:44 +00:00
|
|
|
|
2021-09-06 18:28:26 +00:00
|
|
|
0, // instance-level indentation (should always be 0)
|
2009-10-05 14:40:46 +00:00
|
|
|
};
|
|
|
|
|
2009-10-29 13:32:40 +00:00
|
|
|
// =====================================================================================================
|
2010-08-31 05:14:00 +00:00
|
|
|
// IConsoleWriter (implementations)
|
2009-10-29 13:32:40 +00:00
|
|
|
// =====================================================================================================
|
|
|
|
// (all non-virtual members that do common work and then pass the result through DoWrite
|
|
|
|
// or DoWriteLn)
|
|
|
|
|
2009-11-15 06:26:55 +00:00
|
|
|
// Parameters:
|
|
|
|
// glob_indent - this parameter is used to specify a global indentation setting. It is used by
|
2010-08-06 05:46:09 +00:00
|
|
|
// WriteLn function, but defaults to 0 for Warning and Error calls. Local indentation always
|
2009-11-15 06:26:55 +00:00
|
|
|
// applies to all writes.
|
2021-09-06 18:28:26 +00:00
|
|
|
wxString IConsoleWriter::_addIndentation(const wxString& src, int glob_indent = 0) const
|
2009-11-15 06:26:55 +00:00
|
|
|
{
|
2021-09-06 18:28:26 +00:00
|
|
|
const int indent = glob_indent + _imm_indentation;
|
|
|
|
if (indent == 0)
|
|
|
|
return src;
|
2009-11-15 06:26:55 +00:00
|
|
|
|
2021-09-06 18:28:26 +00:00
|
|
|
wxString result(src);
|
|
|
|
const wxString indentStr(L'\t', indent);
|
|
|
|
result.Replace(L"\n", L"\n" + indentStr);
|
|
|
|
return indentStr + result;
|
2009-11-15 06:26:55 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Sets the indentation to be applied to all WriteLn's. The indentation is added to the
|
|
|
|
// primary write, and to any newlines specified within the write. Note that this applies
|
|
|
|
// to calls to WriteLn *only* -- calls to Write bypass the indentation parser.
|
2021-09-06 18:28:26 +00:00
|
|
|
const IConsoleWriter& IConsoleWriter::SetIndent(int tabcount) const
|
2009-11-15 06:26:55 +00:00
|
|
|
{
|
2021-09-06 18:28:26 +00:00
|
|
|
conlog_Indent += tabcount;
|
|
|
|
pxAssert(conlog_Indent >= 0);
|
|
|
|
return *this;
|
2009-11-15 06:26:55 +00:00
|
|
|
}
|
|
|
|
|
2016-11-12 15:28:37 +00:00
|
|
|
IConsoleWriter IConsoleWriter::Indent(int tabcount) const
|
2009-11-15 06:26:55 +00:00
|
|
|
{
|
2021-09-06 18:28:26 +00:00
|
|
|
IConsoleWriter retval = *this;
|
|
|
|
retval._imm_indentation = tabcount;
|
|
|
|
return retval;
|
2009-11-15 06:26:55 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Changes the active console color.
|
|
|
|
// This color will be unset by calls to colored text methods
|
|
|
|
// such as ErrorMsg and Notice.
|
2021-09-06 18:28:26 +00:00
|
|
|
const IConsoleWriter& IConsoleWriter::SetColor(ConsoleColors color) const
|
2009-11-15 06:26:55 +00:00
|
|
|
{
|
2021-09-06 18:28:26 +00:00
|
|
|
// Ignore current color requests since, well, the current color is already set. ;)
|
|
|
|
if (color == Color_Current)
|
|
|
|
return *this;
|
2010-08-06 05:46:09 +00:00
|
|
|
|
2021-09-06 18:28:26 +00:00
|
|
|
pxAssertMsg((color > Color_Current) && (color < ConsoleColors_Count), "Invalid ConsoleColor specified.");
|
2009-11-18 16:53:44 +00:00
|
|
|
|
2021-09-06 18:28:26 +00:00
|
|
|
if (conlog_Color != color)
|
|
|
|
DoSetColor(conlog_Color = color);
|
2009-11-18 16:53:44 +00:00
|
|
|
|
2021-09-06 18:28:26 +00:00
|
|
|
return *this;
|
2009-11-15 06:26:55 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
ConsoleColors IConsoleWriter::GetColor() const
|
|
|
|
{
|
2021-09-06 18:28:26 +00:00
|
|
|
return conlog_Color;
|
2009-11-15 06:26:55 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Restores the console color to default (usually black, or low-intensity white if the console uses a black background)
|
2021-09-06 18:28:26 +00:00
|
|
|
const IConsoleWriter& IConsoleWriter::ClearColor() const
|
2009-11-15 06:26:55 +00:00
|
|
|
{
|
2021-09-06 18:28:26 +00:00
|
|
|
if (conlog_Color != DefaultConsoleColor)
|
|
|
|
DoSetColor(conlog_Color = DefaultConsoleColor);
|
2009-11-15 06:26:55 +00:00
|
|
|
|
2021-09-06 18:28:26 +00:00
|
|
|
return *this;
|
2009-11-15 06:26:55 +00:00
|
|
|
}
|
|
|
|
|
2009-10-29 13:32:40 +00:00
|
|
|
// --------------------------------------------------------------------------------------
|
|
|
|
// ASCII/UTF8 (char*)
|
|
|
|
// --------------------------------------------------------------------------------------
|
|
|
|
|
2021-09-06 18:28:26 +00:00
|
|
|
bool IConsoleWriter::FormatV(const char* fmt, va_list args) const
|
Lots of new code maintenance stuffs:
* Completely new assertion macros: pxAssert, pxAssertMsg, and pxFail, pxAssertDev (both which default to using a message). These replace *all* wxASSERT, DevAssert, and jASSUME varieties of macros. New macros borrow the best of all assertion worlds: MSVCRT, wxASSERT, and AtlAssume. :)
* Rewrote the Console namespace as a structure called IConsoleWriter, and created several varieties of ConsoleWriters for handling different states of log and console availability (should help reduce overhead of console logging nicely).
* More improvements to the PersistentThread model, using safely interlocked "Do*" style callbacks for starting and cleaning up threads.
* Fixed console logs so that they're readable in Win32 notepad again (the log writer adds CRs to naked LFs).
* Added AppInit.cpp -- contains constructor, destructor, OnInit, and command line parsing mess.
git-svn-id: http://pcsx2.googlecode.com/svn/trunk@1950 96395faa-99c1-11dd-bbfe-3dabce05a288
2009-10-04 08:27:27 +00:00
|
|
|
{
|
2021-09-06 18:28:26 +00:00
|
|
|
DoWriteLn(_addIndentation(pxsFmtV(fmt, args), conlog_Indent));
|
|
|
|
return false;
|
Lots of new code maintenance stuffs:
* Completely new assertion macros: pxAssert, pxAssertMsg, and pxFail, pxAssertDev (both which default to using a message). These replace *all* wxASSERT, DevAssert, and jASSUME varieties of macros. New macros borrow the best of all assertion worlds: MSVCRT, wxASSERT, and AtlAssume. :)
* Rewrote the Console namespace as a structure called IConsoleWriter, and created several varieties of ConsoleWriters for handling different states of log and console availability (should help reduce overhead of console logging nicely).
* More improvements to the PersistentThread model, using safely interlocked "Do*" style callbacks for starting and cleaning up threads.
* Fixed console logs so that they're readable in Win32 notepad again (the log writer adds CRs to naked LFs).
* Added AppInit.cpp -- contains constructor, destructor, OnInit, and command line parsing mess.
git-svn-id: http://pcsx2.googlecode.com/svn/trunk@1950 96395faa-99c1-11dd-bbfe-3dabce05a288
2009-10-04 08:27:27 +00:00
|
|
|
}
|
|
|
|
|
2021-09-06 18:28:26 +00:00
|
|
|
bool IConsoleWriter::WriteLn(const char* fmt, ...) const
|
Lots of new code maintenance stuffs:
* Completely new assertion macros: pxAssert, pxAssertMsg, and pxFail, pxAssertDev (both which default to using a message). These replace *all* wxASSERT, DevAssert, and jASSUME varieties of macros. New macros borrow the best of all assertion worlds: MSVCRT, wxASSERT, and AtlAssume. :)
* Rewrote the Console namespace as a structure called IConsoleWriter, and created several varieties of ConsoleWriters for handling different states of log and console availability (should help reduce overhead of console logging nicely).
* More improvements to the PersistentThread model, using safely interlocked "Do*" style callbacks for starting and cleaning up threads.
* Fixed console logs so that they're readable in Win32 notepad again (the log writer adds CRs to naked LFs).
* Added AppInit.cpp -- contains constructor, destructor, OnInit, and command line parsing mess.
git-svn-id: http://pcsx2.googlecode.com/svn/trunk@1950 96395faa-99c1-11dd-bbfe-3dabce05a288
2009-10-04 08:27:27 +00:00
|
|
|
{
|
2021-09-06 18:28:26 +00:00
|
|
|
va_list args;
|
|
|
|
va_start(args, fmt);
|
|
|
|
FormatV(fmt, args);
|
|
|
|
va_end(args);
|
2009-11-05 19:32:27 +00:00
|
|
|
|
2021-09-06 18:28:26 +00:00
|
|
|
return false;
|
Lots of new code maintenance stuffs:
* Completely new assertion macros: pxAssert, pxAssertMsg, and pxFail, pxAssertDev (both which default to using a message). These replace *all* wxASSERT, DevAssert, and jASSUME varieties of macros. New macros borrow the best of all assertion worlds: MSVCRT, wxASSERT, and AtlAssume. :)
* Rewrote the Console namespace as a structure called IConsoleWriter, and created several varieties of ConsoleWriters for handling different states of log and console availability (should help reduce overhead of console logging nicely).
* More improvements to the PersistentThread model, using safely interlocked "Do*" style callbacks for starting and cleaning up threads.
* Fixed console logs so that they're readable in Win32 notepad again (the log writer adds CRs to naked LFs).
* Added AppInit.cpp -- contains constructor, destructor, OnInit, and command line parsing mess.
git-svn-id: http://pcsx2.googlecode.com/svn/trunk@1950 96395faa-99c1-11dd-bbfe-3dabce05a288
2009-10-04 08:27:27 +00:00
|
|
|
}
|
|
|
|
|
2021-09-06 18:28:26 +00:00
|
|
|
bool IConsoleWriter::WriteLn(ConsoleColors color, const char* fmt, ...) const
|
Lots of new code maintenance stuffs:
* Completely new assertion macros: pxAssert, pxAssertMsg, and pxFail, pxAssertDev (both which default to using a message). These replace *all* wxASSERT, DevAssert, and jASSUME varieties of macros. New macros borrow the best of all assertion worlds: MSVCRT, wxASSERT, and AtlAssume. :)
* Rewrote the Console namespace as a structure called IConsoleWriter, and created several varieties of ConsoleWriters for handling different states of log and console availability (should help reduce overhead of console logging nicely).
* More improvements to the PersistentThread model, using safely interlocked "Do*" style callbacks for starting and cleaning up threads.
* Fixed console logs so that they're readable in Win32 notepad again (the log writer adds CRs to naked LFs).
* Added AppInit.cpp -- contains constructor, destructor, OnInit, and command line parsing mess.
git-svn-id: http://pcsx2.googlecode.com/svn/trunk@1950 96395faa-99c1-11dd-bbfe-3dabce05a288
2009-10-04 08:27:27 +00:00
|
|
|
{
|
2021-09-06 18:28:26 +00:00
|
|
|
va_list args;
|
|
|
|
va_start(args, fmt);
|
|
|
|
ConsoleColorScope cs(color);
|
|
|
|
FormatV(fmt, args);
|
|
|
|
va_end(args);
|
2009-11-05 19:32:27 +00:00
|
|
|
|
2021-09-06 18:28:26 +00:00
|
|
|
return false;
|
Lots of new code maintenance stuffs:
* Completely new assertion macros: pxAssert, pxAssertMsg, and pxFail, pxAssertDev (both which default to using a message). These replace *all* wxASSERT, DevAssert, and jASSUME varieties of macros. New macros borrow the best of all assertion worlds: MSVCRT, wxASSERT, and AtlAssume. :)
* Rewrote the Console namespace as a structure called IConsoleWriter, and created several varieties of ConsoleWriters for handling different states of log and console availability (should help reduce overhead of console logging nicely).
* More improvements to the PersistentThread model, using safely interlocked "Do*" style callbacks for starting and cleaning up threads.
* Fixed console logs so that they're readable in Win32 notepad again (the log writer adds CRs to naked LFs).
* Added AppInit.cpp -- contains constructor, destructor, OnInit, and command line parsing mess.
git-svn-id: http://pcsx2.googlecode.com/svn/trunk@1950 96395faa-99c1-11dd-bbfe-3dabce05a288
2009-10-04 08:27:27 +00:00
|
|
|
}
|
|
|
|
|
2021-09-06 18:28:26 +00:00
|
|
|
bool IConsoleWriter::Error(const char* fmt, ...) const
|
Lots of new code maintenance stuffs:
* Completely new assertion macros: pxAssert, pxAssertMsg, and pxFail, pxAssertDev (both which default to using a message). These replace *all* wxASSERT, DevAssert, and jASSUME varieties of macros. New macros borrow the best of all assertion worlds: MSVCRT, wxASSERT, and AtlAssume. :)
* Rewrote the Console namespace as a structure called IConsoleWriter, and created several varieties of ConsoleWriters for handling different states of log and console availability (should help reduce overhead of console logging nicely).
* More improvements to the PersistentThread model, using safely interlocked "Do*" style callbacks for starting and cleaning up threads.
* Fixed console logs so that they're readable in Win32 notepad again (the log writer adds CRs to naked LFs).
* Added AppInit.cpp -- contains constructor, destructor, OnInit, and command line parsing mess.
git-svn-id: http://pcsx2.googlecode.com/svn/trunk@1950 96395faa-99c1-11dd-bbfe-3dabce05a288
2009-10-04 08:27:27 +00:00
|
|
|
{
|
2021-09-06 18:28:26 +00:00
|
|
|
va_list args;
|
|
|
|
va_start(args, fmt);
|
|
|
|
ConsoleColorScope cs(Color_StrongRed);
|
|
|
|
FormatV(fmt, args);
|
|
|
|
va_end(args);
|
2009-11-05 19:32:27 +00:00
|
|
|
|
2021-09-06 18:28:26 +00:00
|
|
|
return false;
|
Lots of new code maintenance stuffs:
* Completely new assertion macros: pxAssert, pxAssertMsg, and pxFail, pxAssertDev (both which default to using a message). These replace *all* wxASSERT, DevAssert, and jASSUME varieties of macros. New macros borrow the best of all assertion worlds: MSVCRT, wxASSERT, and AtlAssume. :)
* Rewrote the Console namespace as a structure called IConsoleWriter, and created several varieties of ConsoleWriters for handling different states of log and console availability (should help reduce overhead of console logging nicely).
* More improvements to the PersistentThread model, using safely interlocked "Do*" style callbacks for starting and cleaning up threads.
* Fixed console logs so that they're readable in Win32 notepad again (the log writer adds CRs to naked LFs).
* Added AppInit.cpp -- contains constructor, destructor, OnInit, and command line parsing mess.
git-svn-id: http://pcsx2.googlecode.com/svn/trunk@1950 96395faa-99c1-11dd-bbfe-3dabce05a288
2009-10-04 08:27:27 +00:00
|
|
|
}
|
|
|
|
|
2021-09-06 18:28:26 +00:00
|
|
|
bool IConsoleWriter::Warning(const char* fmt, ...) const
|
Lots of new code maintenance stuffs:
* Completely new assertion macros: pxAssert, pxAssertMsg, and pxFail, pxAssertDev (both which default to using a message). These replace *all* wxASSERT, DevAssert, and jASSUME varieties of macros. New macros borrow the best of all assertion worlds: MSVCRT, wxASSERT, and AtlAssume. :)
* Rewrote the Console namespace as a structure called IConsoleWriter, and created several varieties of ConsoleWriters for handling different states of log and console availability (should help reduce overhead of console logging nicely).
* More improvements to the PersistentThread model, using safely interlocked "Do*" style callbacks for starting and cleaning up threads.
* Fixed console logs so that they're readable in Win32 notepad again (the log writer adds CRs to naked LFs).
* Added AppInit.cpp -- contains constructor, destructor, OnInit, and command line parsing mess.
git-svn-id: http://pcsx2.googlecode.com/svn/trunk@1950 96395faa-99c1-11dd-bbfe-3dabce05a288
2009-10-04 08:27:27 +00:00
|
|
|
{
|
2021-09-06 18:28:26 +00:00
|
|
|
va_list args;
|
|
|
|
va_start(args, fmt);
|
|
|
|
ConsoleColorScope cs(Color_StrongOrange);
|
|
|
|
FormatV(fmt, args);
|
|
|
|
va_end(args);
|
2009-11-05 19:32:27 +00:00
|
|
|
|
2021-09-06 18:28:26 +00:00
|
|
|
return false;
|
Lots of new code maintenance stuffs:
* Completely new assertion macros: pxAssert, pxAssertMsg, and pxFail, pxAssertDev (both which default to using a message). These replace *all* wxASSERT, DevAssert, and jASSUME varieties of macros. New macros borrow the best of all assertion worlds: MSVCRT, wxASSERT, and AtlAssume. :)
* Rewrote the Console namespace as a structure called IConsoleWriter, and created several varieties of ConsoleWriters for handling different states of log and console availability (should help reduce overhead of console logging nicely).
* More improvements to the PersistentThread model, using safely interlocked "Do*" style callbacks for starting and cleaning up threads.
* Fixed console logs so that they're readable in Win32 notepad again (the log writer adds CRs to naked LFs).
* Added AppInit.cpp -- contains constructor, destructor, OnInit, and command line parsing mess.
git-svn-id: http://pcsx2.googlecode.com/svn/trunk@1950 96395faa-99c1-11dd-bbfe-3dabce05a288
2009-10-04 08:27:27 +00:00
|
|
|
}
|
|
|
|
|
2009-10-29 13:32:40 +00:00
|
|
|
// --------------------------------------------------------------------------------------
|
2010-08-06 05:46:09 +00:00
|
|
|
// Write Variants - Unicode/UTF16 style
|
2009-10-29 13:32:40 +00:00
|
|
|
// --------------------------------------------------------------------------------------
|
|
|
|
|
2021-09-06 18:28:26 +00:00
|
|
|
bool IConsoleWriter::FormatV(const wxChar* fmt, va_list args) const
|
Lots of new code maintenance stuffs:
* Completely new assertion macros: pxAssert, pxAssertMsg, and pxFail, pxAssertDev (both which default to using a message). These replace *all* wxASSERT, DevAssert, and jASSUME varieties of macros. New macros borrow the best of all assertion worlds: MSVCRT, wxASSERT, and AtlAssume. :)
* Rewrote the Console namespace as a structure called IConsoleWriter, and created several varieties of ConsoleWriters for handling different states of log and console availability (should help reduce overhead of console logging nicely).
* More improvements to the PersistentThread model, using safely interlocked "Do*" style callbacks for starting and cleaning up threads.
* Fixed console logs so that they're readable in Win32 notepad again (the log writer adds CRs to naked LFs).
* Added AppInit.cpp -- contains constructor, destructor, OnInit, and command line parsing mess.
git-svn-id: http://pcsx2.googlecode.com/svn/trunk@1950 96395faa-99c1-11dd-bbfe-3dabce05a288
2009-10-04 08:27:27 +00:00
|
|
|
{
|
2021-09-06 18:28:26 +00:00
|
|
|
DoWriteLn(_addIndentation(pxsFmtV(fmt, args), conlog_Indent));
|
|
|
|
return false;
|
Lots of new code maintenance stuffs:
* Completely new assertion macros: pxAssert, pxAssertMsg, and pxFail, pxAssertDev (both which default to using a message). These replace *all* wxASSERT, DevAssert, and jASSUME varieties of macros. New macros borrow the best of all assertion worlds: MSVCRT, wxASSERT, and AtlAssume. :)
* Rewrote the Console namespace as a structure called IConsoleWriter, and created several varieties of ConsoleWriters for handling different states of log and console availability (should help reduce overhead of console logging nicely).
* More improvements to the PersistentThread model, using safely interlocked "Do*" style callbacks for starting and cleaning up threads.
* Fixed console logs so that they're readable in Win32 notepad again (the log writer adds CRs to naked LFs).
* Added AppInit.cpp -- contains constructor, destructor, OnInit, and command line parsing mess.
git-svn-id: http://pcsx2.googlecode.com/svn/trunk@1950 96395faa-99c1-11dd-bbfe-3dabce05a288
2009-10-04 08:27:27 +00:00
|
|
|
}
|
|
|
|
|
2021-09-06 18:28:26 +00:00
|
|
|
bool IConsoleWriter::WriteLn(const wxChar* fmt, ...) const
|
Lots of new code maintenance stuffs:
* Completely new assertion macros: pxAssert, pxAssertMsg, and pxFail, pxAssertDev (both which default to using a message). These replace *all* wxASSERT, DevAssert, and jASSUME varieties of macros. New macros borrow the best of all assertion worlds: MSVCRT, wxASSERT, and AtlAssume. :)
* Rewrote the Console namespace as a structure called IConsoleWriter, and created several varieties of ConsoleWriters for handling different states of log and console availability (should help reduce overhead of console logging nicely).
* More improvements to the PersistentThread model, using safely interlocked "Do*" style callbacks for starting and cleaning up threads.
* Fixed console logs so that they're readable in Win32 notepad again (the log writer adds CRs to naked LFs).
* Added AppInit.cpp -- contains constructor, destructor, OnInit, and command line parsing mess.
git-svn-id: http://pcsx2.googlecode.com/svn/trunk@1950 96395faa-99c1-11dd-bbfe-3dabce05a288
2009-10-04 08:27:27 +00:00
|
|
|
{
|
2021-09-06 18:28:26 +00:00
|
|
|
va_list args;
|
|
|
|
va_start(args, fmt);
|
|
|
|
FormatV(fmt, args);
|
|
|
|
va_end(args);
|
2009-11-05 19:32:27 +00:00
|
|
|
|
2021-09-06 18:28:26 +00:00
|
|
|
return false;
|
Lots of new code maintenance stuffs:
* Completely new assertion macros: pxAssert, pxAssertMsg, and pxFail, pxAssertDev (both which default to using a message). These replace *all* wxASSERT, DevAssert, and jASSUME varieties of macros. New macros borrow the best of all assertion worlds: MSVCRT, wxASSERT, and AtlAssume. :)
* Rewrote the Console namespace as a structure called IConsoleWriter, and created several varieties of ConsoleWriters for handling different states of log and console availability (should help reduce overhead of console logging nicely).
* More improvements to the PersistentThread model, using safely interlocked "Do*" style callbacks for starting and cleaning up threads.
* Fixed console logs so that they're readable in Win32 notepad again (the log writer adds CRs to naked LFs).
* Added AppInit.cpp -- contains constructor, destructor, OnInit, and command line parsing mess.
git-svn-id: http://pcsx2.googlecode.com/svn/trunk@1950 96395faa-99c1-11dd-bbfe-3dabce05a288
2009-10-04 08:27:27 +00:00
|
|
|
}
|
|
|
|
|
2021-09-06 18:28:26 +00:00
|
|
|
bool IConsoleWriter::WriteLn(ConsoleColors color, const wxChar* fmt, ...) const
|
Lots of new code maintenance stuffs:
* Completely new assertion macros: pxAssert, pxAssertMsg, and pxFail, pxAssertDev (both which default to using a message). These replace *all* wxASSERT, DevAssert, and jASSUME varieties of macros. New macros borrow the best of all assertion worlds: MSVCRT, wxASSERT, and AtlAssume. :)
* Rewrote the Console namespace as a structure called IConsoleWriter, and created several varieties of ConsoleWriters for handling different states of log and console availability (should help reduce overhead of console logging nicely).
* More improvements to the PersistentThread model, using safely interlocked "Do*" style callbacks for starting and cleaning up threads.
* Fixed console logs so that they're readable in Win32 notepad again (the log writer adds CRs to naked LFs).
* Added AppInit.cpp -- contains constructor, destructor, OnInit, and command line parsing mess.
git-svn-id: http://pcsx2.googlecode.com/svn/trunk@1950 96395faa-99c1-11dd-bbfe-3dabce05a288
2009-10-04 08:27:27 +00:00
|
|
|
{
|
2021-09-06 18:28:26 +00:00
|
|
|
va_list args;
|
|
|
|
va_start(args, fmt);
|
|
|
|
ConsoleColorScope cs(color);
|
|
|
|
FormatV(fmt, args);
|
|
|
|
va_end(args);
|
2009-11-05 19:32:27 +00:00
|
|
|
|
2021-09-06 18:28:26 +00:00
|
|
|
return false;
|
Lots of new code maintenance stuffs:
* Completely new assertion macros: pxAssert, pxAssertMsg, and pxFail, pxAssertDev (both which default to using a message). These replace *all* wxASSERT, DevAssert, and jASSUME varieties of macros. New macros borrow the best of all assertion worlds: MSVCRT, wxASSERT, and AtlAssume. :)
* Rewrote the Console namespace as a structure called IConsoleWriter, and created several varieties of ConsoleWriters for handling different states of log and console availability (should help reduce overhead of console logging nicely).
* More improvements to the PersistentThread model, using safely interlocked "Do*" style callbacks for starting and cleaning up threads.
* Fixed console logs so that they're readable in Win32 notepad again (the log writer adds CRs to naked LFs).
* Added AppInit.cpp -- contains constructor, destructor, OnInit, and command line parsing mess.
git-svn-id: http://pcsx2.googlecode.com/svn/trunk@1950 96395faa-99c1-11dd-bbfe-3dabce05a288
2009-10-04 08:27:27 +00:00
|
|
|
}
|
|
|
|
|
2021-09-06 18:28:26 +00:00
|
|
|
bool IConsoleWriter::Error(const wxChar* fmt, ...) const
|
Lots of new code maintenance stuffs:
* Completely new assertion macros: pxAssert, pxAssertMsg, and pxFail, pxAssertDev (both which default to using a message). These replace *all* wxASSERT, DevAssert, and jASSUME varieties of macros. New macros borrow the best of all assertion worlds: MSVCRT, wxASSERT, and AtlAssume. :)
* Rewrote the Console namespace as a structure called IConsoleWriter, and created several varieties of ConsoleWriters for handling different states of log and console availability (should help reduce overhead of console logging nicely).
* More improvements to the PersistentThread model, using safely interlocked "Do*" style callbacks for starting and cleaning up threads.
* Fixed console logs so that they're readable in Win32 notepad again (the log writer adds CRs to naked LFs).
* Added AppInit.cpp -- contains constructor, destructor, OnInit, and command line parsing mess.
git-svn-id: http://pcsx2.googlecode.com/svn/trunk@1950 96395faa-99c1-11dd-bbfe-3dabce05a288
2009-10-04 08:27:27 +00:00
|
|
|
{
|
2021-09-06 18:28:26 +00:00
|
|
|
va_list args;
|
|
|
|
va_start(args, fmt);
|
|
|
|
ConsoleColorScope cs(Color_StrongRed);
|
|
|
|
FormatV(fmt, args);
|
|
|
|
va_end(args);
|
2009-11-05 19:32:27 +00:00
|
|
|
|
2021-09-06 18:28:26 +00:00
|
|
|
return false;
|
Lots of new code maintenance stuffs:
* Completely new assertion macros: pxAssert, pxAssertMsg, and pxFail, pxAssertDev (both which default to using a message). These replace *all* wxASSERT, DevAssert, and jASSUME varieties of macros. New macros borrow the best of all assertion worlds: MSVCRT, wxASSERT, and AtlAssume. :)
* Rewrote the Console namespace as a structure called IConsoleWriter, and created several varieties of ConsoleWriters for handling different states of log and console availability (should help reduce overhead of console logging nicely).
* More improvements to the PersistentThread model, using safely interlocked "Do*" style callbacks for starting and cleaning up threads.
* Fixed console logs so that they're readable in Win32 notepad again (the log writer adds CRs to naked LFs).
* Added AppInit.cpp -- contains constructor, destructor, OnInit, and command line parsing mess.
git-svn-id: http://pcsx2.googlecode.com/svn/trunk@1950 96395faa-99c1-11dd-bbfe-3dabce05a288
2009-10-04 08:27:27 +00:00
|
|
|
}
|
|
|
|
|
2021-09-06 18:28:26 +00:00
|
|
|
bool IConsoleWriter::Warning(const wxChar* fmt, ...) const
|
Lots of new code maintenance stuffs:
* Completely new assertion macros: pxAssert, pxAssertMsg, and pxFail, pxAssertDev (both which default to using a message). These replace *all* wxASSERT, DevAssert, and jASSUME varieties of macros. New macros borrow the best of all assertion worlds: MSVCRT, wxASSERT, and AtlAssume. :)
* Rewrote the Console namespace as a structure called IConsoleWriter, and created several varieties of ConsoleWriters for handling different states of log and console availability (should help reduce overhead of console logging nicely).
* More improvements to the PersistentThread model, using safely interlocked "Do*" style callbacks for starting and cleaning up threads.
* Fixed console logs so that they're readable in Win32 notepad again (the log writer adds CRs to naked LFs).
* Added AppInit.cpp -- contains constructor, destructor, OnInit, and command line parsing mess.
git-svn-id: http://pcsx2.googlecode.com/svn/trunk@1950 96395faa-99c1-11dd-bbfe-3dabce05a288
2009-10-04 08:27:27 +00:00
|
|
|
{
|
2021-09-06 18:28:26 +00:00
|
|
|
va_list args;
|
|
|
|
va_start(args, fmt);
|
|
|
|
ConsoleColorScope cs(Color_StrongOrange);
|
|
|
|
FormatV(fmt, args);
|
|
|
|
va_end(args);
|
2009-11-05 19:32:27 +00:00
|
|
|
|
2021-09-06 18:28:26 +00:00
|
|
|
return false;
|
Lots of new code maintenance stuffs:
* Completely new assertion macros: pxAssert, pxAssertMsg, and pxFail, pxAssertDev (both which default to using a message). These replace *all* wxASSERT, DevAssert, and jASSUME varieties of macros. New macros borrow the best of all assertion worlds: MSVCRT, wxASSERT, and AtlAssume. :)
* Rewrote the Console namespace as a structure called IConsoleWriter, and created several varieties of ConsoleWriters for handling different states of log and console availability (should help reduce overhead of console logging nicely).
* More improvements to the PersistentThread model, using safely interlocked "Do*" style callbacks for starting and cleaning up threads.
* Fixed console logs so that they're readable in Win32 notepad again (the log writer adds CRs to naked LFs).
* Added AppInit.cpp -- contains constructor, destructor, OnInit, and command line parsing mess.
git-svn-id: http://pcsx2.googlecode.com/svn/trunk@1950 96395faa-99c1-11dd-bbfe-3dabce05a288
2009-10-04 08:27:27 +00:00
|
|
|
}
|
|
|
|
|
2014-06-29 06:57:33 +00:00
|
|
|
// --------------------------------------------------------------------------------------
|
|
|
|
// Write Variants - Unknown style
|
|
|
|
// --------------------------------------------------------------------------------------
|
2016-11-12 15:28:37 +00:00
|
|
|
bool IConsoleWriter::WriteLn(const wxString fmt, ...) const
|
2014-06-29 06:57:33 +00:00
|
|
|
{
|
2021-09-06 18:28:26 +00:00
|
|
|
va_list args;
|
|
|
|
va_start(args, fmt);
|
|
|
|
FormatV(fmt.wx_str(), args);
|
|
|
|
va_end(args);
|
2014-06-29 06:57:33 +00:00
|
|
|
|
2021-09-06 18:28:26 +00:00
|
|
|
return false;
|
2014-06-29 06:57:33 +00:00
|
|
|
}
|
|
|
|
|
2016-11-12 15:28:37 +00:00
|
|
|
bool IConsoleWriter::WriteLn(ConsoleColors color, const wxString fmt, ...) const
|
2014-06-29 06:57:33 +00:00
|
|
|
{
|
2021-09-06 18:28:26 +00:00
|
|
|
va_list args;
|
|
|
|
va_start(args, fmt);
|
|
|
|
ConsoleColorScope cs(color);
|
|
|
|
FormatV(fmt.wx_str(), args);
|
|
|
|
va_end(args);
|
2014-06-29 06:57:33 +00:00
|
|
|
|
2021-09-06 18:28:26 +00:00
|
|
|
return false;
|
2014-06-29 06:57:33 +00:00
|
|
|
}
|
|
|
|
|
2016-11-12 15:28:37 +00:00
|
|
|
bool IConsoleWriter::Error(const wxString fmt, ...) const
|
2014-06-29 06:57:33 +00:00
|
|
|
{
|
2021-09-06 18:28:26 +00:00
|
|
|
va_list args;
|
|
|
|
va_start(args, fmt);
|
|
|
|
ConsoleColorScope cs(Color_StrongRed);
|
|
|
|
FormatV(fmt.wx_str(), args);
|
|
|
|
va_end(args);
|
2014-06-29 06:57:33 +00:00
|
|
|
|
2021-09-06 18:28:26 +00:00
|
|
|
return false;
|
2014-06-29 06:57:33 +00:00
|
|
|
}
|
|
|
|
|
2016-11-12 15:28:37 +00:00
|
|
|
bool IConsoleWriter::Warning(const wxString fmt, ...) const
|
2014-06-29 06:57:33 +00:00
|
|
|
{
|
2021-09-06 18:28:26 +00:00
|
|
|
va_list args;
|
|
|
|
va_start(args, fmt);
|
|
|
|
ConsoleColorScope cs(Color_StrongOrange);
|
|
|
|
FormatV(fmt.wx_str(), args);
|
|
|
|
va_end(args);
|
2014-06-29 06:57:33 +00:00
|
|
|
|
2021-09-06 18:28:26 +00:00
|
|
|
return false;
|
2014-06-29 06:57:33 +00:00
|
|
|
}
|
|
|
|
|
2021-01-14 07:13:33 +00:00
|
|
|
bool IConsoleWriter::WriteLn(ConsoleColors color, const std::string& str) const
|
|
|
|
{
|
|
|
|
ConsoleColorScope cs(color);
|
|
|
|
return WriteLn(str);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool IConsoleWriter::WriteLn(const std::string& str) const
|
|
|
|
{
|
|
|
|
DoWriteLn(_addIndentation(fromUTF8(str), conlog_Indent));
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool IConsoleWriter::Error(const std::string& str) const
|
|
|
|
{
|
|
|
|
return WriteLn(Color_StrongRed, str);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool IConsoleWriter::Warning(const std::string& str) const
|
|
|
|
{
|
|
|
|
return WriteLn(Color_StrongOrange, str);
|
|
|
|
}
|
2014-06-29 06:57:33 +00:00
|
|
|
|
2009-12-07 22:43:16 +00:00
|
|
|
// --------------------------------------------------------------------------------------
|
2010-08-06 05:46:09 +00:00
|
|
|
// ConsoleColorScope / ConsoleIndentScope
|
2009-12-07 22:43:16 +00:00
|
|
|
// --------------------------------------------------------------------------------------
|
|
|
|
|
2016-11-12 15:28:37 +00:00
|
|
|
ConsoleColorScope::ConsoleColorScope(ConsoleColors newcolor)
|
2009-12-07 22:43:16 +00:00
|
|
|
{
|
2021-09-06 18:28:26 +00:00
|
|
|
m_IsScoped = false;
|
|
|
|
m_newcolor = newcolor;
|
|
|
|
EnterScope();
|
2010-08-06 05:46:09 +00:00
|
|
|
}
|
2009-12-07 22:43:16 +00:00
|
|
|
|
2017-05-06 12:22:00 +00:00
|
|
|
ConsoleColorScope::~ConsoleColorScope()
|
2010-08-06 05:46:09 +00:00
|
|
|
{
|
2021-09-06 18:28:26 +00:00
|
|
|
LeaveScope();
|
2010-08-06 05:46:09 +00:00
|
|
|
}
|
2009-12-07 22:43:16 +00:00
|
|
|
|
2010-08-06 05:46:09 +00:00
|
|
|
void ConsoleColorScope::EnterScope()
|
|
|
|
{
|
2021-09-06 18:28:26 +00:00
|
|
|
if (!m_IsScoped)
|
|
|
|
{
|
|
|
|
m_old_color = Console.GetColor();
|
|
|
|
Console.SetColor(m_newcolor);
|
|
|
|
m_IsScoped = true;
|
|
|
|
}
|
2009-12-07 22:43:16 +00:00
|
|
|
}
|
|
|
|
|
2010-08-06 05:46:09 +00:00
|
|
|
void ConsoleColorScope::LeaveScope()
|
2009-12-07 22:43:16 +00:00
|
|
|
{
|
2021-09-06 18:28:26 +00:00
|
|
|
m_IsScoped = m_IsScoped && (Console.SetColor(m_old_color), false);
|
2010-08-06 05:46:09 +00:00
|
|
|
}
|
2009-12-07 22:43:16 +00:00
|
|
|
|
2016-11-12 15:28:37 +00:00
|
|
|
ConsoleIndentScope::ConsoleIndentScope(int tabs)
|
2010-08-06 05:46:09 +00:00
|
|
|
{
|
2021-09-06 18:28:26 +00:00
|
|
|
m_IsScoped = false;
|
|
|
|
m_amount = tabs;
|
|
|
|
EnterScope();
|
2010-08-06 05:46:09 +00:00
|
|
|
}
|
2009-12-07 22:43:16 +00:00
|
|
|
|
2017-05-06 12:22:00 +00:00
|
|
|
ConsoleIndentScope::~ConsoleIndentScope()
|
2010-08-06 05:46:09 +00:00
|
|
|
{
|
2021-09-06 18:28:26 +00:00
|
|
|
try
|
|
|
|
{
|
|
|
|
LeaveScope();
|
|
|
|
}
|
|
|
|
DESTRUCTOR_CATCHALL
|
2010-08-06 05:46:09 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void ConsoleIndentScope::EnterScope()
|
|
|
|
{
|
2021-09-06 18:28:26 +00:00
|
|
|
m_IsScoped = m_IsScoped || (Console.SetIndent(m_amount), true);
|
2010-08-06 05:46:09 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void ConsoleIndentScope::LeaveScope()
|
|
|
|
{
|
2021-09-06 18:28:26 +00:00
|
|
|
m_IsScoped = m_IsScoped && (Console.SetIndent(-m_amount), false);
|
2010-08-06 05:46:09 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2016-11-12 15:28:37 +00:00
|
|
|
ConsoleAttrScope::ConsoleAttrScope(ConsoleColors newcolor, int indent)
|
2010-08-06 05:46:09 +00:00
|
|
|
{
|
2021-09-06 18:28:26 +00:00
|
|
|
m_old_color = Console.GetColor();
|
|
|
|
Console.SetIndent(m_tabsize = indent);
|
|
|
|
Console.SetColor(newcolor);
|
2010-08-06 05:46:09 +00:00
|
|
|
}
|
|
|
|
|
2017-05-06 12:22:00 +00:00
|
|
|
ConsoleAttrScope::~ConsoleAttrScope()
|
2010-08-06 05:46:09 +00:00
|
|
|
{
|
2021-09-06 18:28:26 +00:00
|
|
|
try
|
|
|
|
{
|
|
|
|
Console.SetColor(m_old_color);
|
|
|
|
Console.SetIndent(-m_tabsize);
|
|
|
|
}
|
|
|
|
DESTRUCTOR_CATCHALL
|
2009-12-07 22:43:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-10-05 14:40:46 +00:00
|
|
|
// --------------------------------------------------------------------------------------
|
|
|
|
// Default Writer for C++ init / startup:
|
|
|
|
// --------------------------------------------------------------------------------------
|
2010-08-06 05:46:09 +00:00
|
|
|
// Currently all build types default to Stdout, which is very functional on Linux but not
|
|
|
|
// always so useful on Windows (which itself lacks a proper stdout console without using
|
|
|
|
// platform specific code). Under windows Stdout will attempt to write to the IDE Debug
|
|
|
|
// console, if one is available (such as running pcsx2 via MSVC). If not available, then
|
|
|
|
// the log message will pretty much be lost into the ether.
|
2016-11-12 15:28:37 +00:00
|
|
|
//
|
|
|
|
#define _DefaultWriter_ ConsoleWriter_Stdout
|
Lots of new code maintenance stuffs:
* Completely new assertion macros: pxAssert, pxAssertMsg, and pxFail, pxAssertDev (both which default to using a message). These replace *all* wxASSERT, DevAssert, and jASSUME varieties of macros. New macros borrow the best of all assertion worlds: MSVCRT, wxASSERT, and AtlAssume. :)
* Rewrote the Console namespace as a structure called IConsoleWriter, and created several varieties of ConsoleWriters for handling different states of log and console availability (should help reduce overhead of console logging nicely).
* More improvements to the PersistentThread model, using safely interlocked "Do*" style callbacks for starting and cleaning up threads.
* Fixed console logs so that they're readable in Win32 notepad again (the log writer adds CRs to naked LFs).
* Added AppInit.cpp -- contains constructor, destructor, OnInit, and command line parsing mess.
git-svn-id: http://pcsx2.googlecode.com/svn/trunk@1950 96395faa-99c1-11dd-bbfe-3dabce05a288
2009-10-04 08:27:27 +00:00
|
|
|
|
2016-11-12 15:28:37 +00:00
|
|
|
IConsoleWriter Console = _DefaultWriter_;
|
|
|
|
IConsoleWriter DevConWriter = _DefaultWriter_;
|
|
|
|
bool DevConWriterEnabled = false;
|
Lots of new code maintenance stuffs:
* Completely new assertion macros: pxAssert, pxAssertMsg, and pxFail, pxAssertDev (both which default to using a message). These replace *all* wxASSERT, DevAssert, and jASSUME varieties of macros. New macros borrow the best of all assertion worlds: MSVCRT, wxASSERT, and AtlAssume. :)
* Rewrote the Console namespace as a structure called IConsoleWriter, and created several varieties of ConsoleWriters for handling different states of log and console availability (should help reduce overhead of console logging nicely).
* More improvements to the PersistentThread model, using safely interlocked "Do*" style callbacks for starting and cleaning up threads.
* Fixed console logs so that they're readable in Win32 notepad again (the log writer adds CRs to naked LFs).
* Added AppInit.cpp -- contains constructor, destructor, OnInit, and command line parsing mess.
git-svn-id: http://pcsx2.googlecode.com/svn/trunk@1950 96395faa-99c1-11dd-bbfe-3dabce05a288
2009-10-04 08:27:27 +00:00
|
|
|
|
|
|
|
#ifdef PCSX2_DEBUG
|
2016-11-12 15:28:37 +00:00
|
|
|
IConsoleWriter DbgConWriter = _DefaultWriter_;
|
2009-10-05 14:40:46 +00:00
|
|
|
#endif
|
|
|
|
|
2016-11-12 15:28:37 +00:00
|
|
|
NullConsoleWriter NullCon = {};
|
2010-08-06 05:46:09 +00:00
|
|
|
|
|
|
|
// --------------------------------------------------------------------------------------
|
2010-08-16 15:01:13 +00:00
|
|
|
// ConsoleLogSource (implementations)
|
2010-08-06 05:46:09 +00:00
|
|
|
// --------------------------------------------------------------------------------------
|
|
|
|
|
|
|
|
// Writes to the console using the specified color. This overrides the default color setting
|
|
|
|
// for this log.
|
2021-09-06 18:28:26 +00:00
|
|
|
bool ConsoleLogSource::WriteV(ConsoleColors color, const char* fmt, va_list list) const
|
2010-08-06 05:46:09 +00:00
|
|
|
{
|
2021-09-06 18:28:26 +00:00
|
|
|
ConsoleColorScope cs(color);
|
|
|
|
DoWrite(pxsFmtV(fmt, list).c_str());
|
|
|
|
return false;
|
2010-08-06 05:46:09 +00:00
|
|
|
}
|
|
|
|
|
2021-09-06 18:28:26 +00:00
|
|
|
bool ConsoleLogSource::WriteV(ConsoleColors color, const wxChar* fmt, va_list list) const
|
2010-08-06 05:46:09 +00:00
|
|
|
{
|
2021-09-06 18:28:26 +00:00
|
|
|
ConsoleColorScope cs(color);
|
|
|
|
DoWrite(pxsFmtV(fmt, list).c_str());
|
|
|
|
return false;
|
2010-08-06 05:46:09 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Writes to the console using the source's default color. Note that the source's default
|
|
|
|
// color will always be used, thus ConsoleColorScope() will not be effectual unless the
|
|
|
|
// console's default color is Color_Default.
|
2021-09-06 18:28:26 +00:00
|
|
|
bool ConsoleLogSource::WriteV(const char* fmt, va_list list) const
|
2010-08-06 05:46:09 +00:00
|
|
|
{
|
2021-09-06 18:28:26 +00:00
|
|
|
WriteV(DefaultColor, fmt, list);
|
|
|
|
return false;
|
2010-08-06 05:46:09 +00:00
|
|
|
}
|
|
|
|
|
2021-09-06 18:28:26 +00:00
|
|
|
bool ConsoleLogSource::WriteV(const wxChar* fmt, va_list list) const
|
2010-08-06 05:46:09 +00:00
|
|
|
{
|
2021-09-06 18:28:26 +00:00
|
|
|
WriteV(DefaultColor, fmt, list);
|
|
|
|
return false;
|
2010-08-06 05:46:09 +00:00
|
|
|
}
|