Changeset 1601 for XIOS/dev/dev_trunk_omp/src/log.hpp
- Timestamp:
- 11/19/18 15:52:54 (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
XIOS/dev/dev_trunk_omp/src/log.hpp
r523 r1601 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(sBuff), 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<16; i++) 22 strBuf_array[i] = sBuff; 26 23 } 24 25 ~CLog() 26 { 27 omp_destroy_lock( &mutex ); 28 } 29 30 CLog& operator()(int l); 27 31 void setLevel(int l) {level=l; } 28 32 int getLevel() {return level ;} … … 46 50 * \param [in] pointer to new streambuf 47 51 */ 48 void changeStreamBuff(std::streambuf* sBuff) { strBuf_ = sBuff; rdbuf(sBuff); } 52 void changeStreamBuff(std::streambuf* sBuff) 53 { 54 strBuf_ = sBuff; 55 strBuf_array[omp_get_thread_num()] = sBuff; 56 rdbuf(sBuff); 57 } 49 58 50 59 int level ; 51 60 string name ; 52 61 std::streambuf* strBuf_; 62 std::streambuf* strBuf_array[16]; 63 omp_lock_t mutex; 53 64 }; 54 65 … … 56 67 extern CLog report; 57 68 extern CLog error; 69 70 extern std::filebuf* info_FB[16]; 58 71 } 59 72 #endif
Note: See TracChangeset
for help on using the changeset viewer.