유용한 정보

[C++]LogWrite함수

DevReff 2024. 12. 25. 12:16




728x90
반응형

#ifdef _DEBUG_
#include <string.h>
void LogWrite(char *msg, ...)
{
char __msg[2048] = {0,};
va_list vargs;
va_start(vargs, msg);
vsprintf_s(__msg, sizeof(__msg), msg, vargs );
va_end(vargs);

FILE* g_fp = NULL;
char logPath[1024];
GetTempPath(1024, logPath);
std::string path(logPath);
path.append("log.txt");

g_fp = fopen(path.c_str(), "a+");

DWORD dwWrite = 0;
std::string _log(__msg);
_log.append("\n");
size_t ret = fwrite (_log.c_str() , 1 , _log.size() , g_fp);

fclose(g_fp);
}
#endif

 

출처: https://use1348.tistory.com/2 [유용한 정보:티스토리]