FACT++  1.0
void EventImp::Print ( std::ostream &  out,
bool  strip = false 
) const
virtual

Print the contents of the event to the given stream.

Parameters
outAn ostream to which the output should be redirected.
stripdefines whether a possible SERVER name in the event name should be stripped or not.

Definition at line 214 of file EventImp.cc.

References fAllowedStates, Time::GetAsStr(), GetDescription(), GetFormat(), GetName(), GetSize(), GetTime(), i, if(), kBlue, kBold, kGreen, kReset, kYellow, Time::None, Description::SplitDescription(), str, and t.

Referenced by operator()(), and Print().

215 {
216  if (GetDescription().empty())
217  return;
218 
219  out << " -";
220 
221  const string str = GetName();
222  if (!str.empty())
223  out << kBold << str.substr(strip?str.find_first_of('/')+1:0) << kReset << "-";
224 
225  const string fmt = GetFormat();
226 
227  if (!str.empty() && !fmt.empty())
228  out << " ";
229 
230  if (!fmt.empty())
231  out << "[" << fmt << "]";
232 
233  vector<Description> v = Description::SplitDescription(GetDescription());
234 
235  if (!GetDescription().empty())
236  {
237  out << kBold;
238  for (vector<Description>::const_iterator j=v.begin()+1;
239  j!=v.end(); j++)
240  out << " <" << j->name << ">";
241  out << kReset;
242  }
243 
244  for (unsigned int i=0; i<fAllowedStates.size(); i++)
245  out << " " << fAllowedStates[i];
246 
247  const Time tm = GetTime();
248 
249  const bool t = tm!=Time::None && tm!=Time(1970,1,1);
250  const bool s = GetSize()>0;
251 
252  if (s || t)
253  out << "(";
254  if (t)
255  out << tm.GetAsStr("%H:%M:%S.%f");
256  if (s && t)
257  out << "/";
258  if (s)
259  out << "size=" << GetSize();
260  if (s || t)
261  out << ")";
262  out << endl;
263 
264  if (GetDescription().empty())
265  {
266  out << endl;
267  return;
268  }
269 
270  out << " " << v[0].comment << endl;
271 
272  for (vector<Description>::const_iterator j=v.begin()+1;
273  j!=v.end(); j++)
274  {
275  out << " ||" << kGreen << j->name;
276  if (!j->comment.empty())
277  out << kReset << ": " << kBlue << j->comment;
278  if (!j->unit.empty())
279  out << kYellow << " [" << j->unit << "]";
280  out << endl;
281  }
282  out << endl;
283 }
virtual std::string GetDescription() const
Definition: EventImp.h:27
int i
Definition: db_dim_client.c:21
Set color Green.
Definition: WindowLog.h:18
Adds some functionality to boost::posix_time::ptime for our needs.
Definition: Time.h:30
char str[80]
Definition: test_client.c:7
Set color Yellow.
Definition: WindowLog.h:19
std::vector< int > fAllowedStates
Definition: EventImp.h:13
virtual Time GetTime() const
Definition: EventImp.h:57
virtual std::string GetFormat() const
Definition: EventImp.h:52
Set color Blue.
Definition: WindowLog.h:20
static std::vector< Description > SplitDescription(const std::string &buffer)
Definition: Description.cc:82
static const Time None
A none-time, this can be used as a simple representation of an invalid time.
Definition: Time.h:34
virtual std::string GetName() const
Definition: EventImp.h:51
TT t
Definition: test_client.c:26
if(extraDns) new Dns
std::string GetAsStr(const char *fmt="%Y-%m-%d %H:%M:%S") const
Definition: Time.cc:240
Reset all attributes.
Definition: WindowLog.h:29
Set attribute Bold.
Definition: WindowLog.h:36
virtual size_t GetSize() const
Definition: EventImp.h:55

+ Here is the call graph for this function:

+ Here is the caller graph for this function: