Changeset 205 in dev for trunk/jenga/include/common/logger.h
- Timestamp:
- Jul 12, 2007, 2:57:04 AM (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/jenga/include/common/logger.h
r166 r205 13 13 14 14 #include <jenga/include/common/Environment.h> 15 #include <jenga/include/common/BoostXmlSupport.h> 15 16 16 17 #define STDX_DSTREAM_BUFFERING … … 23 24 24 25 26 class LoggerSetting : public BoostXmlSupport<LoggerSetting> 27 { 28 public: 29 int stopStep; 30 31 LoggerSetting() 32 : stopStep( -1 ) 33 { 34 } 35 36 // XMLシリアライズ用 37 private: 38 virtual const char *RootTagName() const 39 { 40 return "loggerSetting"; 41 } 42 friend class boost::serialization::access; 43 template<class Archive> void serialize(Archive& ar, const unsigned int version) 44 { 45 ar & BOOST_SERIALIZATION_NVP( stopStep ); 46 } 47 }; 48 49 25 50 // VC++ で STLport だと using std::char_traits; みたいなのが必要かも 26 51 template <typename Ch_T, typename Tr_T = std::char_traits<Ch_T> > … … 29 54 protected: 30 55 std::string saveFilePath; 56 int count; 57 LoggerSetting setting; 31 58 32 59 public: 33 basic_dbg_streambuf( const std::string &saveFilePath )60 basic_dbg_streambuf( const std::string &saveFilePath, bool isOptionEnabled ) 34 61 : saveFilePath( saveFilePath ) 62 , count( 0 ) 35 63 { 36 64 #ifndef STDX_DSTREAM_BUFFERING 37 65 setbuf(0,0); 38 66 #endif 67 68 if( isOptionEnabled ) 69 { 70 // 設定ファイルを読み込む 71 char temporary[MAX_PATH]; 72 char temp2[MAX_PATH]; 73 char temp3[MAX_PATH]; 74 _splitpath(saveFilePath.c_str(),temporary,temp2,temp3,NULL); 75 setting.Read( (string)temporary + temp2 + temp3 + ".setting.xml", false ); 76 } 39 77 } 40 78 … … 59 97 { 60 98 ofstream ofs( ( saveFilePath ).c_str(), ios_base::app ); 61 ofs << str ;99 ofs << "[" << (count++) << "] " << str ; 62 100 ofs.close(); 101 102 if( (count-1) == setting.stopStep ) 103 { 104 DebugBreak(); 105 } 63 106 } 64 107 … … 67 110 { 68 111 public: 69 basic_dbg_ostream( const string &saveFilePath )70 : std::basic_ostream<Ch_T, Tr_T>(new basic_dbg_streambuf<Ch_T, Tr_T>(saveFilePath ))112 basic_dbg_ostream( const string &saveFilePath, bool isOptionEnabled ) 113 : std::basic_ostream<Ch_T, Tr_T>(new basic_dbg_streambuf<Ch_T, Tr_T>(saveFilePath,isOptionEnabled)) 71 114 { 72 115 ofstream ofs( ( saveFilePath ).c_str(), ios_base::trunc ); … … 87 130 88 131 }} 132 133 BOOST_CLASS_IMPLEMENTATION(Jenga::Common::LoggerSetting, boost::serialization::object_serializable);
Note:
See TracChangeset
for help on using the changeset viewer.