Ignore:
Timestamp:
06/29/22 18:08:55 (2 years ago)
Author:
ymipsl
Message:

Implement new info log method.
Log must be now activated more selectivelly the by level using variable "log_type" key in the xios context.
ex :

<variable id="log_type" type="string">log_protocol</variable>

In code new object CLogType must be created and will be feed as argument to the info object :
ex :
static CLogType logProtocol("log_protocol") ;
...
info(logProtocol)<<"...."

info can be also tested to know if specific key to output log is active :
ex :

if (info.isActive(logProtocol)) ....

Previous method using integer level is still available.

YM

File:
1 edited

Legend:

Unmodified
Added
Removed
  • XIOS/dev/dev_ym/XIOS_COUPLING/src/log.hpp

    r523 r2341  
    55#include <iostream> 
    66#include <string> 
     7#include "log_type.hpp" 
    78 
    89namespace xios 
     
    2526      return *this; 
    2627    } 
     28 
     29    CLog& operator()(CLogType& logType) 
     30    { 
     31      if (logSetting==nullptr) setLogSetting() ; 
     32      if (logSetting->isSet(logType)) 
     33      { 
     34        rdbuf(strBuf_); 
     35        *this<<"-> "<<name<<" : " ; 
     36      } 
     37      else rdbuf(NULL) ; 
     38      return *this; 
     39    } 
     40        
    2741    void setLevel(int l) {level=l; } 
    2842    int getLevel() {return level ;} 
    2943    bool isActive(void) { if (rdbuf()==NULL) return true ; else return false ;} 
    3044    bool isActive(int l) {if (l<=level) return true ; else return false ; } 
     45    bool isActive(CLogType& logType) {if (logSetting==nullptr) setLogSetting() ; if (logSetting->isSet(logType)) return true; else return false; } 
    3146 
    3247  public: 
     
    5166    string name ; 
    5267    std::streambuf* strBuf_; 
     68     
     69    void setLogSetting(void) {logSetting = new CSetLog ;} 
     70 
     71    CSetLog* logSetting = nullptr ; 
    5372  }; 
    5473 
Note: See TracChangeset for help on using the changeset viewer.