21 #include <UtilLib/config.hpp>
22 #include <UtilLib/include/MPIProxy.hpp>
23 #include <UtilLib/include/Log.hpp>
24 #include <UtilLib/include/Exception.hpp>
35 std::string logLevelToString(
const LogLevel& level) {
38 return std::string(
"Error");
41 return std::string(
"Warning");
44 return std::string(
"Info");
47 return std::string(
"Debug");
50 return std::string(
"Debug1");
53 return std::string(
"Debug2");
56 return std::string(
"Debug3");
59 return std::string(
"Debug4");
64 return std::string(
"");
74 void operator()(
void const*)
const {}
81 LogLevel Log::reportingLevel_ = DEBUGLEVEL;
85 std::shared_ptr<std::ostream> Log::pStream_(&std::cerr, null_deleter());
94 "The stream is not available. You can only set the stream to an existing one.");
99 void Log::writeOutput(
const std::string& msg) {
100 std::shared_ptr<std::ostream> pStream =
getStream();
111 tempTm2 = localtime_r(&rawtime, &tempTm1);
113 strftime(outstr,
sizeof(outstr),
"%x% %H:%M:%S", tempTm2);
115 buffer_ <<
"- " << outstr;
116 buffer_ <<
" Proc " << MPIProxy().
getRank() <<
" of "
118 buffer_ << std::setw(10) << logLevelToString(level) <<
":\t";
123 LOG(logINFO) <<
"Report Level changed from "
124 << logLevelToString(reportingLevel_) <<
" to "
125 << logLevelToString(level);
126 reportingLevel_ = level;
130 return reportingLevel_;
134 buffer_ << std::endl;
135 Log::writeOutput(buffer_.str());
static LogLevel getReportingLevel()
static void setStream(std::shared_ptr< std::ostream > pStream)
static void setReportingLevel(LogLevel level)
std::ostringstream & writeReport(LogLevel level=logINFO)
static std::shared_ptr< std::ostream > getStream()