#include <tchar.h> #include <stdio.h> #include <Windows.h> /** \brief 作者 */ #define APPLOG_AUTHOR _T("[author] ") /** \brief 附加信息 */ #define APPLOG_APPEND _T("Communication ") /** \brief 缓存长度 */ #define APPLOG_BUFFER_SIZE (256) /** \brief 应用程序LOG */ #if 1 #define APP_LOG( swzFormat, ... )\ {\ wchar_t swzBuffer[APPLOG_BUFFER_SIZE];\ int idx = 0; \ swprintf_s( swzBuffer+idx, APPLOG_BUFFER_SIZE, _T("%s "), APPLOG_AUTHOR );\ idx += _tcslen(APPLOG_AUTHOR);\ swprintf_s( swzBuffer+idx, APPLOG_BUFFER_SIZE-idx, _T("%s "), APPLOG_APPEND );\ idx += _tcslen(APPLOG_APPEND);\ swprintf_s( swzBuffer+idx, APPLOG_BUFFER_SIZE - idx, swzFormat, __VA_ARGS__ );\ OutputDebugString(swzBuffer);\ } #else #define APP_LOG(swzFormat, ... ) #endif /** \brief 应用程序DEBUG信息 */ #ifdef _DEBUG #define APP_DBG_LOG(swzFormat, ... )\ {\ wchar_t swzBuffer[APPLOG_BUFFER_SIZE];\ int idx = 0;\ swprintf_s( swzBuffer+idx, APPLOG_BUFFER_SIZE, _T("%s "), APPLOG_AUTHOR );\ idx += _tcslen(APPLOG_AUTHOR);\ swprintf_s( swzBuffer+idx, APPLOG_BUFFER_SIZE-idx, _T("%s "), APPLOG_APPEND );\ idx += _tcslen(APPLOG_APPEND);\ swprintf_s( swzBuffer+idx, APPLOG_BUFFER_SIZE - idx, swzFormat, __VA_ARGS__ );\ OutputDebugString(swzBuffer);\ } #else #define APP_DBG_LOG(swzFormat, ... ) #endif