4 #ifndef DUNE_PDELAB_COMMON_LOGTAG_HH
5 #define DUNE_PDELAB_COMMON_LOGTAG_HH
11 #include <dune/common/shared_ptr.hh>
30 extern std::ostream &
logtag(std::ostream &
s);
72 virtual void writeTag(std::ostream &
s)
const = 0;
76 template<
class FormatFunc>
80 FormatFunc formatFunc;
89 formatFunc(formatFunc_)
95 virtual void writeTag(std::ostream &
s)
const { formatFunc(s); }
98 template<
class FormatFunc>
99 shared_ptr<LogtagFormatterBase>
101 {
return make_shared<GeneralLogtagFormatter<FormatFunc> >(formatFunc); }
103 extern shared_ptr<LogtagFormatterBase>
115 = shared_ptr<LogtagFormatterBase>());
121 template<
class FormatFunc>
143 shared_ptr<LogtagFormatterBase> savedFormatter;
146 template<
class FormatFunc>
186 inline const std::string &
str()
const {
return str_; }
205 #endif // DUNE_PDELAB_COMMON_LOGTAG_HH
const shared_ptr< LogtagFormatterBase > & getLogtagFormatter()
get the log tag formatter currently used by logtag()
Definition: logtag.cc:48
void setLogtagFormatFunc(const FormatFunc &formatFunc)
set a new log tag format function to be used by logtag()
Definition: logtag.hh:122
~WithLogtag()
Definition: logtag.cc:65
std::ostream & hostRankWallUserLogtagFormatFunc(std::ostream &s)
logtag format function that includes hostname, rank (if available), wall time and CPU time ...
Definition: logtag.cc:179
std::ostream & operator<<(std::ostream &s, const TimeSpec &t)
insert a timespec into an output stream
Definition: clock.cc:39
void setLogtagFormatter(const shared_ptr< LogtagFormatterBase > &formatter)
set a new log tag formatter to be used by logtag()
Definition: logtag.cc:51
shared_ptr< LogtagFormatterBase > makeGeneralLogtagFormatter(std::ostream &(&formatFunc)(std::ostream &))
Convenience function to create a GeneralLogtagFormatter.
Definition: logtag.cc:32
GeneralLogtagFormatter(const FormatFunc &formatFunc_)
constructor
Definition: logtag.hh:88
Insert standard boilerplate into log messages.
Definition: logtag.hh:181
LocalTag & operator<<(const V &v)
append something to the static boilerplate message
Definition: logtag.hh:190
std::ostream & nullFormatFunc(std::ostream &s)
logtag format function that does not write anything
Definition: logtag.cc:202
const std::string & str() const
extract the static boilerplate message
Definition: logtag.hh:186
A log tag formatter that wraps a unary formatting function or functor.
Definition: logtag.hh:77
virtual void writeTag(std::ostream &s) const
write the tag to the stream
Definition: logtag.hh:95
temporarily use a different log tag format function
Definition: logtag.hh:142
std::ostream & hostPidWallUserLogtagFormatFunc(std::ostream &s)
logtag format function that includes host name, pid, wall time and CPU time
Definition: logtag.cc:192
virtual void writeTag(std::ostream &s) const =0
function that writes the tag to a stream
void setLogtagRank(int rank)
set the rank to be printed by logtag formatters
WithLogtag(const FormatFunc &formatFunc)
Definition: logtag.hh:147
void logtagSetupMPI(bool syncWidthes)
collect MPI information for the logtag formatters
Definition: logtag.cc:90
std::ostream & logtag(std::ostream &s)
function that writes a log tag to some stream
Definition: logtag.cc:59
virtual base class for logger formatters
Definition: logtag.hh:65
const std::string s
Definition: function.hh:1103