52 const
UInt_t TMVA::MsgLogger::fgMaxSourceSize = 25;
54 const
std::
string TMVA::MsgLogger::fgPrefix = "";
55 const
std::
string TMVA::MsgLogger::fgSuffix = ": ";
56 #if __cplusplus > 199711L 65 static std::unique_ptr<const std::map<TMVA::EMsgType, std::string> >
gOwnTypeMap;
66 static std::unique_ptr<const std::map<TMVA::EMsgType, std::string> >
gOwnColorMap;
112 std::ostringstream(),
132 if (&parent !=
this) {
147 std::string source_name;
154 source_name =
"<WARNING>";
157 source_name = source_name.substr( 0, fgMaxSourceSize - 3 );
158 source_name +=
"...";
171 for (std::string::size_type i=source_name.size(); i<
fgMaxSourceSize; i++) source_name.push_back(
' ' );
173 return fgPrefix + source_name +
fgSuffix;
184 std::string message = this->str();
185 std::string::size_type previous_pos = 0, current_pos = 0;
189 current_pos = message.find(
'\n', previous_pos );
190 std::string
line = message.substr( previous_pos, current_pos - previous_pos );
192 std::ostringstream message_to_send;
194 message_to_send.setf( std::ios::adjustfield, std::ios::left );
195 message_to_send.width( fgMaxSourceSize );
196 message_to_send << source_name << fgSuffix <<
line;
197 std::string msg = message_to_send.str();
200 if (current_pos == message.npos)
break;
201 previous_pos = current_pos + 1;
218 std::map<EMsgType, std::string>::const_iterator stype;
225 std::cout << fgPrefix << line << std::endl;
228 std::cout << line << std::endl;
231 std::cout <<
fgColorMap.load()->find( type )->second <<
"<" << stype->second <<
">" << line <<
"\033[0m" << std::endl;
236 if (type ==
kINFO) std::cout << fgPrefix << line << std::endl;
237 else std::cout << fgPrefix <<
"<" << stype->second <<
"> " << line << std::endl;
244 std::cout <<
"***> abort program execution" << std::endl;
245 throw std::runtime_error(
"FATAL error");
267 std::map<TMVA::EMsgType, std::string>*tmp =
new std::map<TMVA::EMsgType, std::string>();
269 (*tmp)[
kVERBOSE] = std::string(
"VERBOSE");
270 (*tmp)[
kDEBUG] = std::string(
"DEBUG");
271 (*tmp)[
kINFO] = std::string(
"INFO");
272 (*tmp)[
kWARNING] = std::string(
"WARNING");
273 (*tmp)[
kERROR] = std::string(
"ERROR");
274 (*tmp)[
kFATAL] = std::string(
"FATAL");
275 (*tmp)[
kSILENT] = std::string(
"SILENT");
276 (*tmp)[
kHEADER] = std::string(
"HEADER");
277 const std::map<TMVA::EMsgType, std::string>* expected=0;
278 if(
fgTypeMap.compare_exchange_strong(expected,tmp)) {
280 gOwnTypeMap.reset(tmp);
288 std::map<TMVA::EMsgType, std::string>*tmp =
new std::map<TMVA::EMsgType, std::string>();
291 (*tmp)[
kDEBUG] = std::string(
"\033[34m");
292 (*tmp)[
kINFO] = std::string(
"");
293 (*tmp)[
kWARNING] = std::string(
"\033[1;31m");
294 (*tmp)[
kERROR] = std::string(
"\033[31m");
295 (*tmp)[
kFATAL] = std::string(
"\033[37;41;1m");
296 (*tmp)[
kSILENT] = std::string(
"\033[30m");
298 const std::map<TMVA::EMsgType, std::string>* expected=0;
299 if(
fgColorMap.compare_exchange_strong(expected,tmp)) {
301 gOwnColorMap.reset(tmp);
void WriteMsg(EMsgType type, const std::string &line) const
putting the output string, the message type, and the color switcher together into a single string ...
void Send()
activates the logger writer
const TObject * fObjSource
static Bool_t fgInhibitOutput
static void InhibitOutput()
static std::unique_ptr< const std::map< TMVA::EMsgType, std::string > > gOwnColorMap
static const std::map< EMsgType, std::string > * fgTypeMap
static const UInt_t fgMaxSourceSize
MsgLogger(const TObject *source, EMsgType minType=kINFO)
constructor
MsgLogger & operator=(const MsgLogger &parent)
assingment operator
std::string GetPrintedSource() const
the full logger prefix
void InitMaps()
Create the message type and color maps.
static const std::string fgSuffix
static MsgLogger & Endmsg(MsgLogger &logger)
end line
static const std::map< EMsgType, std::string > * fgColorMap
std::string GetFormattedSource() const
make sure the source name is no longer than fgMaxSourceSize:
Mother of all ROOT objects.
Abstract ClassifierFactory template that handles arbitrary types.
static std::unique_ptr< const std::map< TMVA::EMsgType, std::string > > gOwnTypeMap
static void EnableOutput()