Skip to content

Instantly share code, notes, and snippets.

@LusainKim
Created November 7, 2015 12:56
Show Gist options
  • Save LusainKim/dc3eb19bc51b1322a518 to your computer and use it in GitHub Desktop.
Save LusainKim/dc3eb19bc51b1322a518 to your computer and use it in GitHub Desktop.
DebugSample
#include <windows.h>
#include <iostream>
#include <string>
#include <fstream>
using namespace std;
#define USE_DEBUG_OUTPUT_TEXT
#if defined(USE_DEBUG_OUTPUT_TEXT)
ofstream fs;
bool bOpenFs = false;
#define DWRITE(str) (fs << (str))
#else
#define DWRITE(str)
#endif
inline void initializeOutputlog()
{
#if defined(USE_DEBUG_OUTPUT_TEXT)
fs.open("log.txt", ios::out | ios::trunc);
fs.imbue(locale("ko-kr"));
bOpenFs = true;
#endif
}
inline void CloseOutputlog()
{
#if defined(USE_DEBUG_OUTPUT_TEXT)
if (bOpenFs) { fs.close(); }
#endif
}
int main()
{
initializeOutputlog();
string str;
while (1)
{
getline(cin,str,'\n');
if (str == "quit") break;
str += '\n';
OutputDebugString(str.c_str());
DWRITE(str);
}
CloseOutputlog();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment