mirror of
https://github.com/edubart/otclient.git
synced 2025-10-17 04:53:27 +02:00
change logger
This commit is contained in:
@@ -36,7 +36,7 @@
|
||||
|
||||
void crashHandler(int signum, siginfo_t* info, void* secret)
|
||||
{
|
||||
logError("Application crashed");
|
||||
g_logger.error("Application crashed");
|
||||
|
||||
std::stringstream ss;
|
||||
ss << stdext::format("app name: %s\n", g_app->getName());
|
||||
@@ -100,7 +100,7 @@ void crashHandler(int signum, siginfo_t* info, void* secret)
|
||||
free(tracebackBuffer);
|
||||
}
|
||||
|
||||
logInfo(ss.str());
|
||||
g_logger.info(ss.str());
|
||||
|
||||
std::string fileName = "crash_report.txt";
|
||||
std::ofstream fout(fileName.c_str(), std::ios::out | std::ios::app);
|
||||
@@ -109,9 +109,9 @@ void crashHandler(int signum, siginfo_t* info, void* secret)
|
||||
fout << ss.str();
|
||||
fout << "\n";
|
||||
fout.close();
|
||||
logInfo("Crash report saved to file %s", fileName.c_str());
|
||||
g_logger.info(stdext::format("Crash report saved to file %s", fileName.c_str()));
|
||||
} else
|
||||
logError("Failed to save crash report!");
|
||||
g_logger.error("Failed to save crash report!");
|
||||
|
||||
signal(SIGILL, SIG_DFL);
|
||||
signal(SIGSEGV, SIG_DFL);
|
||||
|
@@ -124,7 +124,7 @@ LONG CALLBACK ExceptionHandler(LPEXCEPTION_POINTERS e)
|
||||
SymCleanup(GetCurrentProcess());
|
||||
|
||||
// print in stdout
|
||||
logInfo(ss.str());
|
||||
g_logger.info(ss.str());
|
||||
|
||||
// write stacktrace to crash_report.txt
|
||||
char dir[MAX_PATH];
|
||||
@@ -134,9 +134,9 @@ LONG CALLBACK ExceptionHandler(LPEXCEPTION_POINTERS e)
|
||||
if(fout.is_open() && fout.good()) {
|
||||
fout << ss.str();
|
||||
fout.close();
|
||||
logInfo("Crash report saved to file %s", fileName);
|
||||
g_logger.info("Crash report saved to file %s", fileName);
|
||||
} else
|
||||
logError("Failed to save crash report!");
|
||||
g_logger.error("Failed to save crash report!");
|
||||
|
||||
// inform the user
|
||||
std::string msg = stdext::format(
|
||||
|
@@ -203,15 +203,15 @@ void WIN32Window::terminate()
|
||||
{
|
||||
if(m_glContext) {
|
||||
if(!wglMakeCurrent(NULL, NULL))
|
||||
logError("Release of dc and rc failed.");
|
||||
g_logger.error("Release of dc and rc failed.");
|
||||
if(!wglDeleteContext(m_glContext))
|
||||
logError("Release rendering context failed.");
|
||||
g_logger.error("Release rendering context failed.");
|
||||
m_glContext = NULL;
|
||||
}
|
||||
|
||||
if(m_deviceContext) {
|
||||
if(!ReleaseDC(m_window, m_deviceContext))
|
||||
logError("Release device context failed.");
|
||||
g_logger.error("Release device context failed.");
|
||||
m_deviceContext = NULL;
|
||||
}
|
||||
|
||||
@@ -222,13 +222,13 @@ void WIN32Window::terminate()
|
||||
|
||||
if(m_window) {
|
||||
if(!DestroyWindow(m_window))
|
||||
logError("ERROR: Destroy window failed.");
|
||||
g_logger.error("ERROR: Destroy window failed.");
|
||||
m_window = NULL;
|
||||
}
|
||||
|
||||
if(m_instance) {
|
||||
if(!UnregisterClassA(g_app->getName().c_str(), m_instance))
|
||||
logError("UnregisterClassA failed");
|
||||
g_logger.error("UnregisterClassA failed");
|
||||
m_instance = NULL;
|
||||
}
|
||||
}
|
||||
@@ -256,7 +256,7 @@ void WIN32Window::internalRegisterWindowClass()
|
||||
wc.lpszClassName = g_app->getName().c_str();
|
||||
|
||||
if(!RegisterClassA(&wc))
|
||||
logFatal("Failed to register the window class.");
|
||||
g_logger.fatal("Failed to register the window class.");
|
||||
}
|
||||
|
||||
void WIN32Window::internalCreateWindow()
|
||||
@@ -286,13 +286,13 @@ void WIN32Window::internalCreateWindow()
|
||||
NULL);
|
||||
|
||||
if(!m_window)
|
||||
logFatal("Unable to create window");
|
||||
g_logger.fatal("Unable to create window");
|
||||
|
||||
ShowWindow(m_window, SW_HIDE);
|
||||
|
||||
m_deviceContext = GetDC(m_window);
|
||||
if(!m_deviceContext)
|
||||
logFatal("GetDC failed");
|
||||
g_logger.fatal("GetDC failed");
|
||||
}
|
||||
|
||||
void WIN32Window::internalChooseGLVisual()
|
||||
@@ -317,20 +317,20 @@ void WIN32Window::internalChooseGLVisual()
|
||||
|
||||
pixelFormat = ChoosePixelFormat(m_deviceContext, &pfd);
|
||||
if(!pixelFormat)
|
||||
logFatal("Could not find a suitable pixel format");
|
||||
g_logger.fatal("Could not find a suitable pixel format");
|
||||
|
||||
pfd.cStencilBits = 8;
|
||||
if(!SetPixelFormat(m_deviceContext, pixelFormat, &pfd))
|
||||
logFatal("Could not set the pixel format");
|
||||
g_logger.fatal("Could not set the pixel format");
|
||||
}
|
||||
|
||||
void WIN32Window::internalCreateGLContext()
|
||||
{
|
||||
if(!(m_glContext = wglCreateContext(m_deviceContext)))
|
||||
logFatal("Unable to create GL context");
|
||||
g_logger.fatal("Unable to create GL context");
|
||||
|
||||
if(!wglMakeCurrent(m_deviceContext, m_glContext))
|
||||
logFatal("Unable to set GLX context on WIN32 window");
|
||||
g_logger.fatal("Unable to set GLX context on WIN32 window");
|
||||
}
|
||||
|
||||
bool WIN32Window::isExtensionSupported(const char *ext)
|
||||
@@ -679,18 +679,18 @@ void WIN32Window::setMouseCursor(const std::string& file, const Point& hotSpot)
|
||||
|
||||
apng_data apng;
|
||||
if(load_apng(fin, &apng) != 0) {
|
||||
logTraceError("unable to load png file %s", file);
|
||||
g_logger.traceError(stdext::format("unable to load png file %s", file));
|
||||
return;
|
||||
}
|
||||
|
||||
if(apng.bpp != 4) {
|
||||
logError("the cursor png must have 4 channels");
|
||||
g_logger.error("the cursor png must have 4 channels");
|
||||
free_apng(&apng);
|
||||
return;
|
||||
}
|
||||
|
||||
if(apng.width != 32|| apng.height != 32) {
|
||||
logError("the cursor png must have 32x32 dimension");
|
||||
g_logger.error("the cursor png must have 32x32 dimension");
|
||||
free_apng(&apng);
|
||||
return;
|
||||
}
|
||||
@@ -774,7 +774,7 @@ void WIN32Window::setIcon(const std::string& pngIcon)
|
||||
g_resources.loadFile(pngIcon, fin);
|
||||
if(load_apng(fin, &apng) == 0) {
|
||||
if(apng.bpp != 4) {
|
||||
logError("could not set app icon, icon image must have 4 channels");
|
||||
g_logger.error("could not set app icon, icon image must have 4 channels");
|
||||
free_apng(&apng);
|
||||
}
|
||||
|
||||
@@ -807,7 +807,7 @@ void WIN32Window::setIcon(const std::string& pngIcon)
|
||||
|
||||
free_apng(&apng);
|
||||
} else
|
||||
logError("could not load app icon");
|
||||
g_logger.error("could not load app icon");
|
||||
}
|
||||
|
||||
void WIN32Window::setClipboardText(const std::string& text)
|
||||
|
@@ -253,7 +253,7 @@ void X11Window::internalOpenDisplay()
|
||||
{
|
||||
m_display = XOpenDisplay(NULL);
|
||||
if(!m_display)
|
||||
logFatal("Unable to open X11 display");
|
||||
g_logger.fatal("Unable to open X11 display");
|
||||
m_screen = DefaultScreen(m_display);
|
||||
}
|
||||
|
||||
@@ -295,7 +295,7 @@ void X11Window::internalCreateWindow()
|
||||
m_visible = true;
|
||||
|
||||
if(!m_window)
|
||||
logFatal("Unable to create X11 window!");
|
||||
g_logger.fatal("Unable to create X11 window!");
|
||||
|
||||
// ensure window input focus
|
||||
XWMHints hints;
|
||||
@@ -311,7 +311,7 @@ void X11Window::internalCreateWindow()
|
||||
XSetWMProtocols(m_display, m_window, &m_wmDelete , 1);
|
||||
|
||||
if(!internalSetupWindowInput())
|
||||
logWarning("Input of special keys may be messed up, because window input initialization failed");
|
||||
g_logger.warning("Input of special keys may be messed up, because window input initialization failed");
|
||||
|
||||
internalConnectGLContext();
|
||||
}
|
||||
@@ -327,20 +327,20 @@ bool X11Window::internalSetupWindowInput()
|
||||
|
||||
// create input context (to have better key input handling)
|
||||
if(!XSupportsLocale()) {
|
||||
logError("X11 doesn't support the current locale");
|
||||
g_logger.error("X11 doesn't support the current locale");
|
||||
return false;
|
||||
}
|
||||
|
||||
XSetLocaleModifiers("");
|
||||
m_xim = XOpenIM(m_display, NULL, NULL, NULL);
|
||||
if(!m_xim) {
|
||||
logError("XOpenIM failed");
|
||||
g_logger.error("XOpenIM failed");
|
||||
return false;
|
||||
}
|
||||
|
||||
m_xic = XCreateIC(m_xim, XNInputStyle, XIMPreeditNothing | XIMStatusNothing, XNClientWindow, m_window, NULL);
|
||||
if(!m_xic) {
|
||||
logError("Unable to create the input context");
|
||||
g_logger.error("Unable to create the input context");
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -352,13 +352,13 @@ void X11Window::internalCheckGL()
|
||||
#ifdef OPENGL_ES
|
||||
m_eglDisplay = eglGetDisplay((EGLNativeDisplayType)m_display);
|
||||
if(m_eglDisplay == EGL_NO_DISPLAY)
|
||||
logFatal("EGL not supported");
|
||||
g_logger.fatal("EGL not supported");
|
||||
|
||||
if(!eglInitialize(m_eglDisplay, NULL, NULL))
|
||||
logFatal("Unable to initialize EGL");
|
||||
g_logger.fatal("Unable to initialize EGL");
|
||||
#else
|
||||
if(!glXQueryExtension(m_display, NULL, NULL))
|
||||
logFatal("GLX not supported");
|
||||
g_logger.fatal("GLX not supported");
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -377,10 +377,10 @@ void X11Window::internalChooseGLVisual()
|
||||
|
||||
EGLint numConfig;
|
||||
if(!eglChooseConfig(m_eglDisplay, attrList, &m_eglConfig, 1, &numConfig))
|
||||
logFatal("Failed to choose EGL config");
|
||||
g_logger.fatal("Failed to choose EGL config");
|
||||
|
||||
if(numConfig != 1)
|
||||
logWarning("Didn't got the exact EGL config");
|
||||
g_logger.warning("Didn't got the exact EGL config");
|
||||
|
||||
m_rootWindow = DefaultRootWindow(m_display);
|
||||
#else
|
||||
@@ -394,11 +394,11 @@ void X11Window::internalChooseGLVisual()
|
||||
int nelements;
|
||||
m_fbConfig = glXChooseFBConfig(m_display, m_screen, attrList, &nelements);
|
||||
if(!m_fbConfig)
|
||||
logFatal("Couldn't choose RGBA, double buffered fbconfig");
|
||||
g_logger.fatal("Couldn't choose RGBA, double buffered fbconfig");
|
||||
|
||||
m_visual = glXGetVisualFromFBConfig(m_display, *m_fbConfig);
|
||||
if(!m_visual)
|
||||
logFatal("Couldn't choose RGBA, double buffered visual");
|
||||
g_logger.fatal("Couldn't choose RGBA, double buffered visual");
|
||||
|
||||
m_rootWindow = RootWindow(m_display, m_visual->screen);
|
||||
#endif
|
||||
@@ -418,15 +418,15 @@ void X11Window::internalCreateGLContext()
|
||||
|
||||
m_eglContext = eglCreateContext(m_eglDisplay, m_eglConfig, EGL_NO_CONTEXT, attrList);
|
||||
if(m_eglContext == EGL_NO_CONTEXT )
|
||||
logFatal("Unable to create EGL context: %s", eglGetError());
|
||||
g_logger.fatal("Unable to create EGL context: %s", eglGetError());
|
||||
#else
|
||||
m_glxContext = glXCreateContext(m_display, m_visual, NULL, True);
|
||||
|
||||
if(!m_glxContext)
|
||||
logFatal("Unable to create GLX context");
|
||||
g_logger.fatal("Unable to create GLX context");
|
||||
|
||||
if(!glXIsDirect(m_display, m_glxContext))
|
||||
logWarning("GL direct rendering is not possible");
|
||||
g_logger.warning("GL direct rendering is not possible");
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -459,12 +459,12 @@ void X11Window::internalConnectGLContext()
|
||||
#ifdef OPENGL_ES
|
||||
m_eglSurface = eglCreateWindowSurface(m_eglDisplay, m_eglConfig, m_window, NULL);
|
||||
if(m_eglSurface == EGL_NO_SURFACE)
|
||||
logFatal("Unable to create EGL surface: %s", eglGetError());
|
||||
g_logger.fatal("Unable to create EGL surface: %s", eglGetError());
|
||||
if(!eglMakeCurrent(m_eglDisplay, m_eglSurface, m_eglSurface, m_eglContext))
|
||||
logFatal("Unable to connect EGL context into X11 window");
|
||||
g_logger.fatal("Unable to connect EGL context into X11 window");
|
||||
#else
|
||||
if(!glXMakeCurrent(m_display, m_window, m_glxContext))
|
||||
logFatal("Unable to set GLX context on X11 window");
|
||||
g_logger.fatal("Unable to set GLX context on X11 window");
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -712,7 +712,7 @@ void X11Window::poll()
|
||||
break;
|
||||
std::string text = buf;
|
||||
|
||||
//logDebug("char: ", buf[0], " code: ", (int)((uchar)buf[0]));
|
||||
//g_logger.debug("char: ", buf[0], " code: ", (int)((uchar)buf[0]));
|
||||
|
||||
if(m_onInputEvent && text.length() > 0) {
|
||||
m_inputEvent.reset(Fw::KeyTextInputEvent);
|
||||
@@ -843,18 +843,18 @@ void X11Window::setMouseCursor(const std::string& file, const Point& hotSpot)
|
||||
|
||||
apng_data apng;
|
||||
if(load_apng(fin, &apng) != 0) {
|
||||
logTraceError("unable to load png file %s", file);
|
||||
g_logger.traceError(stdext::format("unable to load png file %s", file));
|
||||
return;
|
||||
}
|
||||
|
||||
if(apng.bpp != 4) {
|
||||
logError("the cursor png must have 4 channels");
|
||||
g_logger.error("the cursor png must have 4 channels");
|
||||
free_apng(&apng);
|
||||
return;
|
||||
}
|
||||
|
||||
if(apng.width != 32|| apng.height != 32) {
|
||||
logError("the cursor png must have 32x32 dimension");
|
||||
g_logger.error("the cursor png must have 32x32 dimension");
|
||||
free_apng(&apng);
|
||||
return;
|
||||
}
|
||||
@@ -961,12 +961,12 @@ void X11Window::setIcon(const std::string& iconFile)
|
||||
|
||||
apng_data apng;
|
||||
if(load_apng(fin, &apng) != 0) {
|
||||
logError("Unable to load window icon");
|
||||
g_logger.error("Unable to load window icon");
|
||||
return;
|
||||
}
|
||||
|
||||
if(apng.bpp != 4) {
|
||||
logError("Could not set window icon, icon image must have 4 channels");
|
||||
g_logger.error("Could not set window icon, icon image must have 4 channels");
|
||||
free_apng(&apng);
|
||||
return;
|
||||
}
|
||||
@@ -985,7 +985,7 @@ void X11Window::setIcon(const std::string& iconFile)
|
||||
|
||||
Atom property = XInternAtom(m_display, "_NET_WM_ICON", 0);
|
||||
if(!XChangeProperty(m_display, m_window, property, XA_CARDINAL, 32, PropModeReplace, (const unsigned char*)&iconData[0], iconData.size()))
|
||||
logError("Couldn't set app icon");
|
||||
g_logger.error("Couldn't set app icon");
|
||||
|
||||
free_apng(&apng);
|
||||
}
|
||||
|
Reference in New Issue
Block a user