Create log.cpp

master
Kirigaya Kazuto 2018-05-26 11:28:08 +08:00 committed by GitHub
parent 5f5fa5c89a
commit 84b75b1306
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 22 additions and 0 deletions

22
log.cpp Normal file
View File

@ -0,0 +1,22 @@
#include <string>
using namespace std;
#ifdef _WIN32
#include <Windows.h>
#else
#include <pthread.h>
#endif
string _log_whichThread()
{
char buff[32] = { 0 };
#ifdef _WIN32
sprintf(buff, "%ul", GetCurrentThreadId()); // DWORD
#else
sprintf(buff, "%ul", pthread_self());
#endif
string ans("Thread ");
ans.append(buff);
return ans;
}