Changeset 490 for XIOS/trunk/src/log.hpp


Ignore:
Timestamp:
09/26/14 14:52:04 (10 years ago)
Author:
mhnguyen
Message:

Implementing print output in seperate files

+) Add an option to write information into standard output or into files,
each of which is created by a process
+) Add a new file for global data (constant, value macro, etc)
+) Do a minor change in how to generate doxygen

Test
+) On Curie, with two modes: only client (connected) and client-server
+) All tests passed, each client prints out its info in a seperate file

File:
1 edited

Legend:

Unmodified
Added
Removed
  • XIOS/trunk/src/log.hpp

    r380 r490  
    1313  { 
    1414    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) 
    1919      { 
    20         rdbuf(cout.rdbuf()) ; 
     20//        rdbuf(cout.rdbuf()) ; 
     21        rdbuf(strBuf_); 
    2122        *this<<"-> "<<name<<" : " ; 
    2223      } 
     
    2425      return *this; 
    2526    } 
    26     void setLevel(int l) {level=l; }  
     27    void setLevel(int l) {level=l; } 
    2728    int getLevel() {return level ;} 
    2829    bool isActive(void) { if (rdbuf()==NULL) return true ; else return false ;} 
    2930    bool isActive(int l) {if (l<=level) return true ; else return false ; } 
    3031 
     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 
    3146    private : 
    3247    int level ; 
    3348    string name ; 
     49    std::streambuf* strBuf_; 
    3450  }; 
    3551 
Note: See TracChangeset for help on using the changeset viewer.