C++ logging library Based on the https://blog.csdn.net/sinat_21107433/article/details/103102542
- Windows 10-11
- Color terminal output is supported
- Custom log output location (terminal/file)
- support Unicode
- A more comprehensive definition
Copy all files to the project
#include "log.h"
#include <process.h>
#include <Windows.h>
#define THREAD_NUM 5
int g_num = 0;
unsigned int __stdcall func(void *pPM)
{
LOG_INFO("enter");
//int nThreadNum = *(int *)pPM;
Sleep(50);
g_num++;
LOG_INFO("g_num = %d", g_num);
LOG_DEBUG("fsafas");
LOG_INFO("exit");
LOG_WARNING("!!!");
LOG_ERROR("xxx");
return 0;
}
int main()
{
//BLADE_FILE_LOG(); //输出至文件
BLADE_CONSOLE_LOG(); //输出至终端
HANDLE handle[THREAD_NUM];
int threadNum = 0;
while (threadNum < THREAD_NUM)
{
handle[threadNum] = (HANDLE)_beginthreadex(NULL, 0, func, NULL, 0, NULL);
threadNum++;
}
WaitForMultipleObjects(THREAD_NUM, handle, TRUE, INFINITE);
return 0;
}