Peano 4
Loading...
Searching...
No Matches
LogFilter.h
Go to the documentation of this file.
1// This file is part of the Peano project. For conditions of distribution and
2// use, please see the copyright notice at www.peano-framework.org
3#pragma once
4
5#include <string>
6#include <set>
7#include <stack>
8
9namespace tarch {
10 namespace logging {
11 class LogFilter;
12 }
13}
14
21 private:
23
24 public:
31 static const int AnyRank;
32
33 static const std::string TargetAll;
34 static const std::string TargetInfo;
35 static const std::string TargetDebug;
36 static const std::string TargetTrace;
37 static const std::string TargetWarning;
38
39 static const std::string AlwaysOn;
40
41 static const bool BlackListEntry;
42 static const bool WhiteListEntry;
43
50 std::string _targetName;
51
58 int _rank;
59
63 std::string _namespaceName;
64
69
74 std::string _programPhase;
75
76 bool operator<(const FilterListEntry& b) const;
77 bool operator==(const FilterListEntry& b) const;
78 bool operator!=(const FilterListEntry& b) const;
79
83 FilterListEntry( const std::string& targetName="", bool isBlackListEntry=false );
84 FilterListEntry( const std::string& targetName, int rank, const std::string& className, bool isBlackListEntry, const std::string& programPhase );
85
86 std::string toString() const;
87 };
88
89 typedef std::set<FilterListEntry> FilterList;
90
92
93 #if !defined(SharedMemoryParallelisation) && PeanoDebug>=1
94 std::stack<std::string> _indentTraces;
95 #endif
96
100 LogFilter();
101
102
109 bool filterOut(
110 const std::string& targetName,
111 const std::string& className
112 );
113
114 public:
115 static LogFilter& getInstance();
116
117 ~LogFilter();
118
128 void addFilterListEntry( const FilterListEntry& entry);
129 void addFilterListEntries( const FilterList& entries);
130 void clearFilterList();
131 void printFilterListToCout() const;
132
133 bool writeDebug(const std::string& trace);
134 bool writeInfo(const std::string& trace);
135 bool writeTrace(const std::string& trace);
136 bool writeWarning(const std::string& trace);
137
138 void switchProgramPhase(const std::string& activeProgramPhase);
139};
Peano4's log filter is used by every single log instance.
Definition LogFilter.h:20
void addFilterListEntry(const FilterListEntry &entry)
Add one filter list entry.
bool writeInfo(const std::string &trace)
std::set< FilterListEntry > FilterList
Definition LogFilter.h:89
bool writeWarning(const std::string &trace)
bool writeDebug(const std::string &trace)
void printFilterListToCout() const
Definition LogFilter.cpp:98
void switchProgramPhase(const std::string &activeProgramPhase)
void addFilterListEntries(const FilterList &entries)
LogFilter()
By default, everything is on.
Definition LogFilter.cpp:82
std::string _activeProgramPhase
Definition LogFilter.h:22
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.
Have to include this header, as I need access to the SYCL_EXTERNAL keyword.
Definition accelerator.h:17
Represents one entry of the filter list.
Definition LogFilter.h:30
static const std::string TargetTrace
Definition LogFilter.h:36
static const std::string TargetDebug
Definition LogFilter.h:35
static const std::string TargetInfo
Definition LogFilter.h:34
bool operator!=(const FilterListEntry &b) const
Definition LogFilter.cpp:78
std::string _namespaceName
Name of the namespace that should not be logged.
Definition LogFilter.h:63
bool operator<(const FilterListEntry &b) const
Definition LogFilter.cpp:64
static const std::string TargetAll
Definition LogFilter.h:33
static const std::string AlwaysOn
Definition LogFilter.h:39
static const std::string TargetWarning
Definition LogFilter.h:37
bool _isBlackEntry
If true, filter list entry is a filter list entry, otherwise white list.
Definition LogFilter.h:68
FilterListEntry(const std::string &targetName="", bool isBlackListEntry=false)
Construct filter list entry for one target without any.
Definition LogFilter.cpp:26
int _rank
Sometimes, one wants to block all log entries of one namespace of one node (parallel case).
Definition LogFilter.h:58
bool operator==(const FilterListEntry &b) const
Definition LogFilter.cpp:71
std::string _programPhase
AlwaysOn if the filter entry applies for all phases.
Definition LogFilter.h:74
std::string _targetName
The message type target can be either "debug" or "info".
Definition LogFilter.h:50