#pragma once #include #include //streamsize #include //basic_streambuf #include //char_traits, basic_string #include //char_traits, basic_string #include #include #include #include #include #define STDX_DSTREAM_BUFFERING using namespace std; namespace Jenga{ namespace Common{ // VC++ で STLport だと using std::char_traits; みたいなのが必要かも template > class basic_dbg_streambuf: public std::basic_stringbuf { public: basic_dbg_streambuf() { #ifndef STDX_DSTREAM_BUFFERING setbuf(0,0); #endif } virtual ~basic_dbg_streambuf() { sync(); } protected: int sync(void) { dbg_out(str().c_str()); pbump(static_cast(pbase() - pptr())); return 0; } void dbg_out(const Ch_T*); }; template <> inline void basic_dbg_streambuf::dbg_out(const char *str) { ofstream ofs( ( Environment::GetAppDir() + "\\logger.log" ).c_str(), ios_base::app ); ofs << str ; ofs.close(); } template > class basic_dbg_ostream: public std::basic_ostream { public: basic_dbg_ostream() : std::basic_ostream(new \ basic_dbg_streambuf()) { ofstream ofs( ( Environment::GetAppDir() + "\\logger.log" ).c_str(), ios_base::trunc ); ofs.close(); } virtual ~basic_dbg_ostream() { // flush(); // 不要らしい.http://www.tietew.jp/cppll/archive/607 delete rdbuf(); } }; static basic_dbg_ostream<_TCHAR> logger; }}