Changeset 166 in dev for trunk/jenga/include
- Timestamp:
- Jun 17, 2007, 9:55:40 PM (17 years ago)
- Location:
- trunk/jenga/include/common
- Files:
-
- 1 added
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/jenga/include/common/logger.h
r164 r166 27 27 class basic_dbg_streambuf: public std::basic_stringbuf<Ch_T, Tr_T> 28 28 { 29 protected: 30 std::string saveFilePath; 31 29 32 public: 30 basic_dbg_streambuf() 31 { 33 basic_dbg_streambuf( const std::string &saveFilePath ) 34 : saveFilePath( saveFilePath ) 35 { 32 36 #ifndef STDX_DSTREAM_BUFFERING 33 37 setbuf(0,0); 34 38 #endif 35 39 } 36 40 37 38 39 40 41 virtual ~basic_dbg_streambuf() 42 { 43 sync(); 44 } 41 45 42 46 protected: 43 44 45 46 47 48 47 int sync(void) 48 { 49 dbg_out(str().c_str()); 50 pbump(static_cast<int>(pbase() - pptr())); 51 return 0; 52 } 49 53 50 54 void dbg_out(const Ch_T*); 51 55 }; 52 56 … … 54 58 inline void basic_dbg_streambuf<char>::dbg_out(const char *str) 55 59 { 56 ofstream ofs( ( Environment::GetAppDir() + "\\logger.log").c_str(), ios_base::app );60 ofstream ofs( ( saveFilePath ).c_str(), ios_base::app ); 57 61 ofs << str ; 58 62 ofs.close(); … … 63 67 { 64 68 public: 65 basic_dbg_ostream() : std::basic_ostream<Ch_T, Tr_T>(new \ 66 basic_dbg_streambuf<Ch_T, Tr_T>())67 68 ofstream ofs( ( Environment::GetAppDir() + "\\logger.log").c_str(), ios_base::trunc );69 basic_dbg_ostream( const string &saveFilePath ) 70 : std::basic_ostream<Ch_T, Tr_T>(new basic_dbg_streambuf<Ch_T, Tr_T>(saveFilePath)) 71 { 72 ofstream ofs( ( saveFilePath ).c_str(), ios_base::trunc ); 69 73 ofs.close(); 70 74 } 71 75 72 virtual ~basic_dbg_ostream() 73 { 74 // flush(); // 不要らしい.http://www.tietew.jp/cppll/archive/607 75 delete rdbuf(); 76 } 76 77 virtual ~basic_dbg_ostream() 78 { 79 // flush(); // 不要らしい.http://www.tietew.jp/cppll/archive/607 80 delete rdbuf(); 81 } 77 82 }; 78 83 79 84 80 static basic_dbg_ostream<_TCHAR> logger;85 typedef basic_dbg_ostream<_TCHAR> Logger; 81 86 82 87
Note:
See TracChangeset
for help on using the changeset viewer.