27 _targetName(targetName),
30 _isBlackEntry(isBlackListEntry),
31 _programPhase(AlwaysOn) {
36 _targetName(targetName),
38 _namespaceName(className),
39 _isBlackEntry(isBlackListEntry),
40 _programPhase(programPhase) {
45 std::ostringstream msg;
47 msg <<
"target:" << _targetName <<
",";
48 msg << _namespaceName <<
",";
50 msg <<
"rank:" << _rank;
54 msg <<
"blacklist-entry";
57 msg <<
"whitelist-entry";
59 msg <<
",phase:" << _programPhase;
65 return _rank < b._rank
66 or _namespaceName < b._namespaceName
67 or _targetName < b._targetName
68 or _programPhase < b._programPhase;
72 return _rank == b._rank
73 and _namespaceName == b._namespaceName
74 and _targetName == b._targetName
75 and _programPhase == b._programPhase;
85 #if defined(UseLikwid)
92 #if defined(UseLikwid)
93 likwid_markerStopRegion( _activeProgramPhase.c_str() );
99 if (_filterlist.empty()) {
100 std::cout <<
"filter list is empty" << std::endl;
102 std::cout <<
"filter list is not empty and contains " << _filterlist.size() <<
" entries" << std::endl;
103 for (FilterList::const_iterator p = _filterlist.begin(); p!=_filterlist.end(); p++ ) {
104 std::cout << p->toString() << std::endl;
116 std::cout <<
"switch program phase to " << activeProgramPhase <<
" and, hence, activate potentially different filter set" << std::endl;
119 _activeProgramPhase = activeProgramPhase;
121 #if defined(UseLikwid)
122 likwid_markerStopRegion( _activeProgramPhase.c_str() );
123 likwid_markerStartRegion( _activeProgramPhase.c_str() );
129 return !filterOut(FilterListEntry::TargetDebug,className);
136 return !filterOut(FilterListEntry::TargetInfo,className);
140 return !filterOut(FilterListEntry::TargetWarning,className);
145 const bool result = !filterOut(FilterListEntry::TargetTrace,className);
153 for (FilterList::const_iterator p = entries.begin(); p!=entries.end(); p++ ) {
154 addFilterListEntry(*p);
163 const std::string& targetName,
164 const std::string& className
167 bool foundRule =
false;
168 int lengthActive = 0;
169 for (FilterList::const_iterator p = _filterlist.begin(); p!=_filterlist.end(); p++ ) {
170 int length =
static_cast<int>(p->_namespaceName.size());
171 if ( length >= lengthActive ) {
173 ( targetName == p->_targetName or p->_targetName==FilterListEntry::TargetAll )
175 ( _activeProgramPhase.find( p->_programPhase,0 )==0 or p->_programPhase==FilterListEntry::AlwaysOn )
177 ( className.find(p->_namespaceName,0)==0 )
183 lengthActive = length;
184 result = p->_isBlackEntry;
191 std::cerr <<
"did not find filter rule for target \"" << targetName <<
"\" and class \"" << className <<
"\" on rank " <<
tarch::mpi::Rank::getInstance().
getRank() << std::endl;
197 if (_filterlist.count(entry)!=0) {
198 std::cerr <<
"tried to insert log filter " << entry.
toString() <<
" multiple times" << std::endl;
201 _filterlist.insert( entry );
#define assertion1(expr, param)
bool operator==(const swift2::TaskNumber &lhs, const swift2::TaskNumber &rhs)
Peano4's log filter is used by every single log instance.
void addFilterListEntry(const FilterListEntry &entry)
Add one filter list entry.
bool writeInfo(const std::string &trace)
std::set< FilterListEntry > FilterList
bool writeWarning(const std::string &trace)
bool writeDebug(const std::string &trace)
void printFilterListToCout() const
void switchProgramPhase(const std::string &activeProgramPhase)
void addFilterListEntries(const FilterList &entries)
LogFilter()
By default, everything is on.
std::string _activeProgramPhase
bool writeTrace(const std::string &trace)
static LogFilter & getInstance()
bool filterOut(const std::string &targetName, const std::string &className)
May not be const as it might write a warning itself.
static Rank & getInstance()
This operation returns the singleton instance.
int getRank() const
Return rank of this node.
Represents one entry of the filter list.
static const std::string TargetTrace
static const std::string TargetDebug
static const std::string TargetInfo
bool operator!=(const FilterListEntry &b) const
static const bool WhiteListEntry
std::string toString() const
bool operator<(const FilterListEntry &b) const
static const std::string TargetAll
static const std::string AlwaysOn
static const std::string TargetWarning
static const bool BlackListEntry
FilterListEntry(const std::string &targetName="", bool isBlackListEntry=false)
Construct filter list entry for one target without any.
bool operator==(const FilterListEntry &b) const