1
0
forked from 0ad/0ad

Send log messages to the console

This was SVN commit r704.
This commit is contained in:
Ykkrosh 2004-07-11 16:03:26 +00:00
parent 9cead7eab8
commit f2dc64e75d
4 changed files with 36 additions and 5 deletions

View File

@ -572,7 +572,7 @@ void ParseArgs(int argc, char* argv[])
if (val=g_ConfigDB.GetValue(CFG_SYSTEM, "shadows"))
val->GetBool(g_Shadows);
LOG(NORMAL, "g_x/yres is %dx%d\n", g_xres, g_yres);
LOG(NORMAL, "g_x/yres is %dx%d", g_xres, g_yres);
}
@ -582,7 +582,7 @@ static void psInit()
g_Font_Console = unifont_load("fonts/console");
g_Font_Misc = unifont_load("fonts/verdana16");
g_Console = new CConsole(0, g_yres-600.f, (float)g_xres, 600.f);
g_Console->SetSize(0, g_yres-600.f, (float)g_xres, 600.f);
g_Console->m_iFontHeight = unifont_linespacing(g_Font_Console);
g_Console->m_iFontOffset = 9;
@ -637,6 +637,11 @@ PREVTSC=TSC;
_control87(_PC_24, _MCW_PC);
#endif
// Set up the console early, so that debugging
// messages can be logged to it. (The console's size
// and fonts are set later in psInit())
g_Console = new CConsole();
// Create the scripting host. This needs to be done before the GUI is created.
new ScriptingHost;

View File

@ -9,8 +9,7 @@
#include "scripting/ScriptingHost.h"
CConsole::CConsole(float X, float Y, float W, float H)
: m_fX(X), m_fY(Y), m_fWidth(W), m_fHeight(H)
CConsole::CConsole()
{
m_bToggle = false;
@ -37,6 +36,15 @@ CConsole::~CConsole()
}
void CConsole::SetSize(float X, float Y, float W, float H)
{
m_fX = X;
m_fY = Y;
m_fWidth = W;
m_fHeight = H;
}
void CConsole::FlushBuffer(void)
{
/* Clear the buffer and set the cursor and length to 0 */

View File

@ -62,9 +62,11 @@ private:
void ProcessBuffer(const wchar_t* szLine);
public:
CConsole(float X = 300, float Y = 0, float W = 800, float H = 600); //1152x864
CConsole();
~CConsole();
void SetSize(float X = 300, float Y = 0, float W = 800, float H = 600);
void Update(float DeltaTime);
void Render();

View File

@ -3,6 +3,13 @@
#include "CLogger.h"
#include "lib.h"
#define CONSOLE_DEBUG
#ifdef CONSOLE_DEBUG
#include "CConsole.h"
extern CConsole* g_Console;
#endif
using namespace std;
#define MAIN_HEADER "<HTML>\n<HEAD>\n<LINK REL=StyleSheet HREF=" \
@ -81,6 +88,9 @@ CLogger::~CLogger ()
void CLogger::WriteMessage(const char *message)
{
#ifdef CONSOLE_DEBUG
g_Console->InsertMessage(L"LOG: %S", message);
#endif
m_NumberOfMessages++;
m_MainLog << "<P>" << message << "</P>";
@ -90,6 +100,9 @@ void CLogger::WriteMessage(const char *message)
void CLogger::WriteError(const char *message)
{
#ifdef CONSOLE_DEBUG
g_Console->InsertMessage(L"ERROR: %S", message);
#endif
debug_out("ERROR: %s\n", message);
m_NumberOfErrors++;
m_MainLog << "<P class=\"error\">ERROR: "<< message << "</P>\n";
@ -98,6 +111,9 @@ void CLogger::WriteError(const char *message)
void CLogger::WriteWarning(const char *message)
{
#ifdef CONSOLE_DEBUG
g_Console->InsertMessage(L"WARNING: %S", message);
#endif
m_NumberOfWarnings++;
m_MainLog << "<P class=\"warning\">WARNING: "<< message << "</P>\n";