iCub-main
diagnosticInfo.cpp
Go to the documentation of this file.
1 /*
2  * Copyright (C) Istituto Italiano di Tecnologia (IIT)
3  * All rights reserved.
4  *
5  * This software may be modified and distributed under the terms of the
6  * BSD-3-Clause license. See the accompanying LICENSE file for details.
7  */
8 
9 #include <string>
10 #include "diagnosticInfo.h"
11 #include <yarp/os/LogStream.h>
12 
13 
14 using namespace Diagnostic;
15 
16 
17 /**************************************************************************************************************************/
18 /****************************************** TimeOfInfo ***************************************************/
19 /**************************************************************************************************************************/
20 
21 void TimeOfInfo::toString(std::string &str_toi)
22 {
23  char str[50];
24  snprintf(str, sizeof(str), "%ds %dm %du", sec, msec, usec);
25  str_toi.clear();
26  str_toi.append(str);
27 }
28 
29 
30 
31 /**************************************************************************************************************************/
32 /****************************************** Info ***************************************************/
33 /**************************************************************************************************************************/
34 
36 {
37  if (finalMessage.size() == 0)
38  return;
39 
40  std::string str_toi;
41  timeOfInfo.toString(str_toi);
42 
43  std::string final_str = "from BOARD " + sourceBoardIpAddrStr + " (" + sourceBoardName +") time=" + str_toi + " : " + finalMessage;
44  switch(severity)
45  {
47  {
48  yInfo() << final_str;
49  } break;
50 
52  {
53  yDebug() << final_str;
54  } break;
55 
57  {
58  yWarning() << final_str;
59  } break;
60 
62  {
63  yError() << final_str;
64  } break;
65 
67  {
68  yError() << "EMS received the following FATAL error: " <<final_str;
69  } break;
70 
71  default:
72  {
73  yError() << final_str;
74  } break;
75  }
76 
77 
78 }
79 
Diagnostic::TimeOfInfo timeOfInfo
Diagnostic::SeverityOfError severity
std::string sourceBoardIpAddrStr
void toString(std::string &str_toi)