Changeset 490 for XIOS/trunk/src/log.hpp
- Timestamp:
- 09/26/14 14:52:04 (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
XIOS/trunk/src/log.hpp
r380 r490 13 13 { 14 14 public : 15 CLog(const string& name_) : ostream(cout.rdbuf()),level(0),name(name_) {}16 CLog& operator()(int l) 17 { 18 if (l<=level) 15 CLog(const string& name_) : ostream(cout.rdbuf()),level(0),name(name_), strBuf_(cout.rdbuf()) {} 16 CLog& operator()(int l) 17 { 18 if (l<=level) 19 19 { 20 rdbuf(cout.rdbuf()) ; 20 // rdbuf(cout.rdbuf()) ; 21 rdbuf(strBuf_); 21 22 *this<<"-> "<<name<<" : " ; 22 23 } … … 24 25 return *this; 25 26 } 26 void setLevel(int l) {level=l; } 27 void setLevel(int l) {level=l; } 27 28 int getLevel() {return level ;} 28 29 bool isActive(void) { if (rdbuf()==NULL) return true ; else return false ;} 29 30 bool isActive(int l) {if (l<=level) return true ; else return false ; } 30 31 32 public: 33 //! Write info into a file with its streambuf 34 void write2File(std::streambuf* sBuff) { changeStreamBuff(sBuff); } 35 36 //! Write info into standard output 37 void write2StdOut() { changeStreamBuff(cout.rdbuf()); } 38 private: 39 /*! 40 * \brief Change current streambuf (by default std::cout) to new one 41 * This function associates a new streambuf to the current log object 42 * \param [in] pointer to new streambuf 43 */ 44 void changeStreamBuff(std::streambuf* sBuff) { strBuf_ = sBuff; rdbuf(sBuff); } 45 31 46 private : 32 47 int level ; 33 48 string name ; 49 std::streambuf* strBuf_; 34 50 }; 35 51
Note: See TracChangeset
for help on using the changeset viewer.