FACT++  1.0
int MessageImp::WriteImp ( const Time time,
const std::string &  txt,
int  severity = kMessage 
)
private

Mjd of last message.

The basic implementation of the output of a message to the output stream. This can overwritten by inheriting classes. The default is to redirect the message to the stream fOut. In addition colors from WindowLog are used depending on the severity. The color are ignored if the stream is not of type WindowLog.

The default message has the form:

2011-02-22 11:13:32.000754 - Text message.

while ## is a placeholder depending on the severity of the message, e.g.

kMessage:  default    ->
kInfo:     green      I>
kWarn:     yellow     W>
kError:    red        E>
kAlarm     red        E>
kFatal:    red-blink  !>
kDebug:    blue
default:   bold       >>
Parameters
timeThe time assigned to the message
txtThe message text
severityThe severity of the message

Definition at line 108 of file MessageImp.cc.

References fOut, Time::GetAsStr(), kAlarm, kBlink, kBlue, kBold, kComment, kDebug, kDefault, kError, kFatal, kGreen, kInfo, kMessage, kRed, kWarn, kYellow, and Memory::mtx.

Referenced by Write().

109 {
110  if (severity==kAlarm && txt.length()==0)
111  return 0;
112 
113  static mutex mtx;
114  const lock_guard<mutex> guard(mtx);
115 
116  switch (severity)
117  {
118  case kMessage: fOut << kDefault << " -> "; break;
119  case kComment: fOut << kDefault << " #> "; break;
120  case kInfo: fOut << kGreen << " I> "; break;
121  case kWarn: fOut << kYellow << " W> "; break;
122  case kError:
123  case kAlarm: fOut << kRed << " E> "; break;
124  case kFatal: fOut << kRed << kBlink << " !> "; break;
125  case kDebug: fOut << kBlue << " "; break;
126  default: fOut << kBold << " >> "; break;
127  }
128  fOut << time.GetAsStr("%H:%M:%S.%f") << " - " << txt << endl;
129 
130  return 0;
131 }
std::mutex mtx
Definition: EventBuilder.cc:95
A warning, things that somehow might result in unexpected or unwanted bahaviour.
Definition: MessageImp.h:18
Set color Green.
Definition: WindowLog.h:18
Set color Yellow.
Definition: WindowLog.h:19
Set attribute Blink.
Definition: WindowLog.h:34
Set color Red.
Definition: WindowLog.h:17
Set default colors.
Definition: WindowLog.h:16
An info telling something which can be interesting to know.
Definition: MessageImp.h:17
Just a message, usually obsolete.
Definition: MessageImp.h:16
A message used for debugging only.
Definition: MessageImp.h:23
std::ostream & fOut
Definition: MessageImp.h:27
Set color Blue.
Definition: WindowLog.h:20
Error, something unexpected happened, but can still be handled by the program.
Definition: MessageImp.h:19
A comment which is always printed.
Definition: MessageImp.h:22
Error, something unexpected happened, but needs user intervention (i.e. it needs a signal to the user...
Definition: MessageImp.h:20
std::string GetAsStr(const char *fmt="%Y-%m-%d %H:%M:%S") const
Definition: Time.cc:240
An error which cannot be handled at all happend, the only solution is program termination.
Definition: MessageImp.h:21
Set attribute Bold.
Definition: WindowLog.h:36

+ Here is the call graph for this function:

+ Here is the caller graph for this function: