mirror of https://github.com/axmolengine/axmol.git
By default, make cocos2d::log multi-threading safe
This commit is contained in:
parent
63e7c6e4dc
commit
7e7fba9649
|
@ -70,6 +70,16 @@
|
||||||
#include "win32-specific/ntcvt/ntcvt.hpp"
|
#include "win32-specific/ntcvt/ntcvt.hpp"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
// !FIXME: the previous version of cocos2d::log not thread safe
|
||||||
|
// since egnx make it multi-threading safe by default
|
||||||
|
#if !defined(CC_LOG_MULTITHREAD)
|
||||||
|
#define CC_LOG_MULTITHREAD 1
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if !defined(CC_CONSOLE_CONSOLE)
|
||||||
|
#define CC_OUTPUT_LOG_TO_CONSOLE 1
|
||||||
|
#endif
|
||||||
|
|
||||||
NS_CC_BEGIN
|
NS_CC_BEGIN
|
||||||
|
|
||||||
extern const char* cocos2dVersion(void);
|
extern const char* cocos2dVersion(void);
|
||||||
|
@ -145,12 +155,18 @@ void log(const char * format, ...)
|
||||||
// print to debugger output window
|
// print to debugger output window
|
||||||
std::wstring wbuf = ntcvt::from_chars(buf);
|
std::wstring wbuf = ntcvt::from_chars(buf);
|
||||||
|
|
||||||
|
OutputDebugStringW(wbuf.c_str());
|
||||||
|
|
||||||
|
#if CC_OUTPUT_LOG_TO_CONSOLE
|
||||||
// print to console if possible
|
// print to console if possible
|
||||||
wprintf(L"%s", wbuf.c_str());
|
wprintf(L"%s", wbuf.c_str());
|
||||||
fflush(stdout);
|
fflush(stdout);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if !CC_LOG_MULTITHREAD
|
||||||
// print to log window
|
// print to log window
|
||||||
SendLogToWindow(buf.c_str());
|
SendLogToWindow(buf.c_str());
|
||||||
|
#endif
|
||||||
#else
|
#else
|
||||||
buf.push_back('\n');
|
buf.push_back('\n');
|
||||||
// Linux, Mac, iOS, etc
|
// Linux, Mac, iOS, etc
|
||||||
|
@ -158,7 +174,9 @@ void log(const char * format, ...)
|
||||||
fflush(stdout);
|
fflush(stdout);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if !CC_LOG_MULTITHREAD
|
||||||
Director::getInstance()->getConsole()->log(buf.c_str());
|
Director::getInstance()->getConsole()->log(buf.c_str());
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
// FIXME: Deprecated
|
// FIXME: Deprecated
|
||||||
|
|
Loading…
Reference in New Issue