From 1b50e0586ab04aa5f827be5eb0d77b7b0593f72b Mon Sep 17 00:00:00 2001 From: Vadim Lopatin Date: Fri, 27 Mar 2015 11:39:55 +0300 Subject: [PATCH] platform initialization/deinitialization refactoring --- src/dlangui/platforms/common/platform.d | 22 ++++++++++++++++++---- src/dlangui/platforms/sdl/sdlapp.d | 14 ++------------ src/dlangui/platforms/windows/winapp.d | 8 ++------ 3 files changed, 22 insertions(+), 22 deletions(-) diff --git a/src/dlangui/platforms/common/platform.d b/src/dlangui/platforms/common/platform.d index cd187639..b0ce2a5f 100644 --- a/src/dlangui/platforms/common/platform.d +++ b/src/dlangui/platforms/common/platform.d @@ -222,10 +222,10 @@ class Window { measure(); //Log.d("measured size: ", _mainWidget.measuredWidth, "x", _mainWidget.measuredHeight); long measureEnd = currentTimeMillis; - Log.d("measure took ", measureEnd - measureStart, " ms"); + debug Log.d("resize: measure took ", measureEnd - measureStart, " ms"); layout(); long layoutEnd = currentTimeMillis; - Log.d("layout took ", layoutEnd - measureEnd, " ms"); + debug Log.d("resize: layout took ", layoutEnd - measureEnd, " ms"); //Log.d("layout position: ", _mainWidget.pos); } update(true); @@ -986,7 +986,7 @@ class Window { if (!needLayout) { needLayout = root.needLayout || needLayout; if (needLayout) { - Log.d("need layout: ", root.id); + debug(DebugRedraw) Log.d("need layout: ", root.id); } } if (root.animating && root.visible) @@ -1566,4 +1566,18 @@ void releaseResourcesOnAppExit() { } } } -} \ No newline at end of file +} + +/// initialize logging (for win32 - to file ui.log, for other platforms - stderr; log level is TRACE for debug builds, and WARN for release builds) +void initLogs() { + version (Windows) { + Log.setFileLogger(std.stdio.File("ui.log", "w")); + } else { + Log.setStderrLogger(); + } + debug { + Log.setLogLevel(LogLevel.Trace); + } else { + Log.setLogLevel(LogLevel.Warn); + } +} diff --git a/src/dlangui/platforms/sdl/sdlapp.d b/src/dlangui/platforms/sdl/sdlapp.d index 37d5c2ba..b05d1948 100644 --- a/src/dlangui/platforms/sdl/sdlapp.d +++ b/src/dlangui/platforms/sdl/sdlapp.d @@ -1237,12 +1237,7 @@ version (Windows) { int myWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int iCmdShow) { - Log.setFileLogger(std.stdio.File("ui.log", "w")); - debug { - Log.setLogLevel(LogLevel.Trace); - } else { - Log.setLogLevel(LogLevel.Warn); - } + initLogs(); Log.d("myWinMain()"); string basePath = exePath(); Log.i("Current executable: ", exePath()); @@ -1268,12 +1263,7 @@ version (Windows) { int main(string[] args) { - Log.setStderrLogger(); - debug { - Log.setLogLevel(LogLevel.Trace); - } else { - Log.setLogLevel(LogLevel.Warn); - } + initLogs(); if (!initFontManager()) { Log.e("******************************************************************"); diff --git a/src/dlangui/platforms/windows/winapp.d b/src/dlangui/platforms/windows/winapp.d index e170382f..8f7036ec 100644 --- a/src/dlangui/platforms/windows/winapp.d +++ b/src/dlangui/platforms/windows/winapp.d @@ -929,12 +929,8 @@ private __gshared Win32Platform w32platform; int myWinMain(void* hInstance, void* hPrevInstance, char* lpCmdLine, int iCmdShow) { - Log.setFileLogger(std.stdio.File("ui.log", "w")); - debug { - Log.setLogLevel(LogLevel.Trace); - } else { - Log.setLogLevel(LogLevel.Info); - } + initLogs(); + Log.d("myWinMain()"); string basePath = exePath(); Log.i("Current executable: ", exePath());