new logger

scripts are now more error prone
This commit is contained in:
Eduardo Bart
2011-04-22 15:48:02 -03:00
parent e611734396
commit 96e0b1e909
30 changed files with 181 additions and 178 deletions

View File

@@ -211,7 +211,7 @@ void Platform::init(const char *appName)
wc.lpszClassName = win32.appName.c_str(); // Set The Class Name
if(!RegisterClassA(&wc))
logFatal("Failed to register the window class.");
logFatal("FATAL ERROR: Failed to register the window class.");
// force first tick
Platform::getTicks();
@@ -226,7 +226,7 @@ void Platform::terminate()
if(win32.instance) {
if(!UnregisterClassA(win32.appName.c_str(), win32.instance))
logError("Unregister class failed.");
logError("ERROR: Unregister class failed.");
win32.instance = NULL;
}
@@ -286,7 +286,7 @@ bool Platform::createWindow(int x, int y, int width, int height, int minWidth, i
if(!win32.window) {
terminate();
logFatal("Window creation error.");
logFatal("FATAL ERROR: Window creation error.");
return false;
}
@@ -315,31 +315,31 @@ bool Platform::createWindow(int x, int y, int width, int height, int minWidth, i
if(!(win32.hdc = GetDC(win32.window))) {
terminate();
logFatal("Can't Create A GL Device Context.");
logFatal("FATAL ERROR: Can't Create A GL Device Context.");
return false;
}
if(!(pixelFormat = ChoosePixelFormat(win32.hdc, &pfd))) {
terminate();
logFatal("Can't Find A Suitable PixelFormat.");
logFatal("FATAL ERROR: Can't Find A Suitable PixelFormat.");
return false;
}
if(!SetPixelFormat(win32.hdc, pixelFormat, &pfd)) {
terminate();
logFatal("Can't Set The PixelFormat.");
logFatal("FATAL ERROR: Can't Set The PixelFormat.");
return false;
}
if(!(win32.hrc = wglCreateContext(win32.hdc))) {
terminate();
logFatal("Can't Create A GL Rendering Context.");
logFatal("FATAL ERROR: Can't Create A GL Rendering Context.");
return false;
}
if(!wglMakeCurrent(win32.hdc, win32.hrc)) {
terminate();
logFatal("Can't Activate The GL Rendering Context.");
logFatal("FATAL ERROR: Can't Activate The GL Rendering Context.");
return false;
}
@@ -350,24 +350,24 @@ void Platform::destroyWindow()
{
if(win32.hrc) {
if(!wglMakeCurrent(NULL, NULL))
logError("Release Of DC And RC Failed.");
logError("ERROR: Release Of DC And RC Failed.");
if(!wglDeleteContext(win32.hrc))
logError("Release Rendering Context Failed.");
logError("ERROR: Release Rendering Context Failed.");
win32.hrc = NULL;
}
if(win32.hdc) {
if(!ReleaseDC(win32.window, win32.hdc))
logError("Release Device Context Failed.");
logError("ERROR: Release Device Context Failed.");
win32.hdc = NULL;
}
if(win32.window) {
if(!DestroyWindow(win32.window))
logError("Destroy window failed.");
logError("ERROR: Destroy window failed.");
win32.window = NULL;
}
@@ -502,7 +502,7 @@ std::string Platform::getAppUserDir()
std::stringstream sdir;
sdir << PHYSFS_getUserDir() << "/." << win32.appName << "/";
if((mkdir(sdir.str().c_str()) != 0) && (errno != EEXIST))
logError("Couldn't create directory for saving configuration file. (%s)", sdir.str().c_str());
logError("ERROR: Couldn't create directory for saving configuration file. (%s)", sdir.str().c_str());
return sdir.str();
}

View File

@@ -234,18 +234,18 @@ void Platform::init(const char *appName)
// open display
x11.display = XOpenDisplay(0);
if(!x11.display)
logFatal("Failed to open X display");
logFatal("FATAL ERROR: Failed to open X display");
// check if GLX is supported on this display
if(!glXQueryExtension(x11.display, 0, 0))
logFatal("GLX not supported");
logFatal("FATAL ERROR: GLX not supported");
// retrieve GLX version
int glxMajor;
int glxMinor;
if(!glXQueryVersion(x11.display, &glxMajor, &glxMinor))
logFatal("Unable to query GLX version");
logInfo("GLX version %d.%d", glxMajor, glxMinor);
logFatal("FATAL ERROR: Unable to query GLX version");
flogInfo("GLX version %d.%d", glxMajor % glxMinor);
// clipboard related atoms
x11.atomClipboard = XInternAtom(x11.display, "CLIPBOARD", False);
@@ -497,12 +497,12 @@ bool Platform::createWindow(int x, int y, int width, int height, int minWidth, i
// choose OpenGL, RGBA, double buffered, visual
x11.visual = glXChooseVisual(x11.display, DefaultScreen(x11.display), attrList);
if(!x11.visual)
logFatal("RGBA/Double buffered visual not supported");
logFatal("FATAL ERROR: RGBA/Double buffered visual not supported");
// create GLX context
x11.glxContext = glXCreateContext(x11.display, x11.visual, 0, GL_TRUE);
if(!x11.glxContext)
logFatal("Unable to create GLX context");
logFatal("FATAL ERROR: Unable to create GLX context");
// color map
x11.colormap = XCreateColormap(x11.display,
@@ -535,7 +535,7 @@ bool Platform::createWindow(int x, int y, int width, int height, int minWidth, i
&wa);
if(!x11.window)
logFatal("Unable to create X window");
logFatal("FATAL ERROR: Unable to create X window");
// create input context (to have better key input handling)
if(XSupportsLocale()) {
@@ -547,11 +547,11 @@ bool Platform::createWindow(int x, int y, int width, int height, int minWidth, i
XIMPreeditNothing | XIMStatusNothing,
XNClientWindow, x11.window, NULL);
if(!x11.xic)
logError("Unable to create the input context");
logError("ERROR: Unable to create the input context");
} else
logError("Failed to open an input method");
logError("ERROR: Failed to open an input method");
} else
logError("X11 does not support the current locale");
logError("ERROR: X11 does not support the current locale");
if(!x11.xic)
logWarning("Input of special keys maybe messed up because we couldn't create an input context");
@@ -836,6 +836,6 @@ std::string Platform::getAppUserDir()
std::stringstream sdir;
sdir << PHYSFS_getUserDir() << "/." << x11.appName << "/";
if((mkdir(sdir.str().c_str(), S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH) != 0) && (errno != EEXIST))
logError("Couldn't create directory for saving configuration file. (%s)", sdir.str().c_str());
flogError("ERROR: Couldn't create directory for saving configuration file. (%s)", sdir.str().c_str());
return sdir.str();
}