mirror of https://github.com/axmolengine/axmol.git
Merge pull request #9619 from yinjimmy/trackLogForWindows
Track log for windows
This commit is contained in:
commit
3581c00301
|
@ -201,6 +201,25 @@ static const char* inet_ntop(int af, const void* src, char* dst, int cnt)
|
|||
}
|
||||
#endif
|
||||
|
||||
static const int CCLOG_STRING_TAG = 1;
|
||||
void SendLogToWindow(const char *log)
|
||||
{
|
||||
#if (CC_TARGET_PLATFORM == CC_PLATFORM_WIN32)
|
||||
// Send data as a message
|
||||
COPYDATASTRUCT myCDS;
|
||||
myCDS.dwData = CCLOG_STRING_TAG;
|
||||
myCDS.cbData = (DWORD)strlen(log) + 1;
|
||||
myCDS.lpData = (PVOID)log;
|
||||
if (Director::getInstance()->getOpenGLView())
|
||||
{
|
||||
HWND hwnd = Director::getInstance()->getOpenGLView()->getWin32Window();
|
||||
SendMessage(hwnd,
|
||||
WM_COPYDATA,
|
||||
(WPARAM)(HWND)hwnd,
|
||||
(LPARAM)(LPVOID)&myCDS);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
//
|
||||
// Free functions to log
|
||||
|
@ -222,6 +241,7 @@ static void _log(const char *format, va_list args)
|
|||
OutputDebugStringW(wszBuf);
|
||||
WideCharToMultiByte(CP_ACP, 0, wszBuf, -1, buf, sizeof(buf), nullptr, FALSE);
|
||||
printf("%s", buf);
|
||||
SendLogToWindow(buf);
|
||||
fflush(stdout);
|
||||
#else
|
||||
// Linux, Mac, iOS, etc
|
||||
|
|
|
@ -51,7 +51,6 @@ typedef SSIZE_T ssize_t;
|
|||
#include "base/ccMacros.h"
|
||||
#include "platform/CCPlatformMacros.h"
|
||||
|
||||
|
||||
NS_CC_BEGIN
|
||||
|
||||
/// The max length of CCLog message.
|
||||
|
|
Loading…
Reference in New Issue