Changeset 1128 for XIOS/dev/branch_yushan/src/log.hpp
- Timestamp:
- 05/11/17 16:12:23 (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
XIOS/dev/branch_yushan/src/log.hpp
r1081 r1128 5 5 #include <iostream> 6 6 #include <string> 7 #include <stdio.h> 8 #include <omp.h> 7 9 8 10 namespace xios … … 14 16 public : 15 17 CLog(const string& name_, std::streambuf* sBuff = cout.rdbuf()) 16 : ostream(sBuff), level(0), name(name_), strBuf_(sBuff) {} 17 CLog& operator()(int l) 18 : ostream(cout.rdbuf()), level(0), name(name_), strBuf_(sBuff) 18 19 { 19 if (l<=level) 20 { 21 rdbuf(strBuf_); 22 *this<<"-> "<<name<<" : " ; 23 } 24 else rdbuf(NULL) ; 25 return *this; 20 omp_init_lock( &mutex ); 21 for(int i=0; i<10; i++) 22 strBuf_array[i] = sBuff; 26 23 } 24 25 ~CLog() 26 { 27 omp_destroy_lock( &mutex ); 28 } 29 30 31 CLog& operator()(int l); 27 32 void setLevel(int l) {level=l; } 28 33 int getLevel() {return level ;} … … 46 51 * \param [in] pointer to new streambuf 47 52 */ 48 void changeStreamBuff(std::streambuf* sBuff) { strBuf_ = sBuff; rdbuf(sBuff); } 53 void changeStreamBuff(std::streambuf* sBuff) 54 { 55 strBuf_ = sBuff; 56 strBuf_array[omp_get_thread_num()] = sBuff; 57 rdbuf(sBuff); 58 } 49 59 50 60 int level ; 51 61 string name ; 52 62 std::streambuf* strBuf_; 63 std::streambuf* strBuf_array[10]; 64 omp_lock_t mutex; 53 65 }; 54 66 … … 56 68 extern CLog report; 57 69 extern CLog error; 70 71 72 extern std::filebuf* info_FB[10]; 73 74 58 75 } 59 76 #endif
Note: See TracChangeset
for help on using the changeset viewer.