修改 cocos2dx/platform/CCPlatformMacros.h,為 CCLOG 系列宏添加日誌級別標籤,便於過濾與調試。
// 第 218 行左右
#define CCLOGERROR(format, ...) cocos2d::CCLog("[error]" format, ##__VA_ARGS__)
// 第 224 行左右
#define CCLOGERROR(format, ...) cocos2d::CCLog("[error]" format, ##__VA_ARGS__)
#define CCLOGINFO(format, ...) cocos2d::CCLog("[info]" format, ##__VA_ARGS__)
CCLOGERROR("Failed to load resource: %s", filename);
CCLOGINFO("Player entered level %d", level);
[error] Failed to load resource: hero.png [info] Player entered level 3
[warn], [debug] 等級別。__FILE__, __LINE__, __FUNCTION__ 宏輸出位置信息。CCLOGINFO/CCLOGDEBUG。微小的宏改動能大幅提升團隊協作開發中的日誌可讀性與調試效率,是引擎層面的「低成本高收益」優化。