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  std::string str_toi;
38  timeOfInfo.toString(str_toi);
39 
40  std::string final_str = "from BOARD " + sourceBoardIpAddrStr + " (" + sourceBoardName +") time=" + str_toi + " : " + finalMessage;
41  switch(severity)
42  {
44  {
45  yInfo() << final_str;
46  } break;
47 
49  {
50  yDebug() << final_str;
51  } break;
52 
54  {
55  yWarning() << final_str;
56  } break;
57 
59  {
60  yError() << final_str;
61  } break;
62 
64  {
65  yError() << "EMS received the following FATAL error: " <<final_str;
66  } break;
67 
68  default:
69  {
70  yError() << final_str;
71  } break;
72  }
73 
74 
75 }
76 
Diagnostic::TimeOfInfo timeOfInfo
Diagnostic::SeverityOfError severity
std::string sourceBoardIpAddrStr
void toString(std::string &str_toi)