Analysis Software
Documentation for sPHENIX simulation software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
MessageSystem.cc
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file MessageSystem.cc
1 #include "MessageSystem.h"
2 
3 #include "OnlMonBase.h" // for OnlMonBase
4 #include "OnlMonServer.h"
5 
6 #include <Event/msg_control.h>
7 #include <Event/msg_profile.h> // for MSG_SEV_DEFAULT, MSG_SEV_INFORMATIONAL
8 
9 #include <iostream> // for endl, ostream, basic_ostream, cout, std
10 
12  : OnlMonBase(name)
13 {
15  return;
16 }
17 
19 {
20  delete Message;
21  msgcounter.clear();
22  return;
23 }
24 
25 int MessageSystem::send_message(const int msgsource, const int severity, const std::string &err_message, const int msgtype)
26 {
27  Message->set_source(msgsource);
28  Message->set_severity(severity);
29  std::map<int, std::pair<int, int> >::iterator iter;
30 tryagain:
31  iter = msgcounter.find(msgtype);
32  if (iter == msgcounter.end())
33  {
34  std::pair<int, int> newpair(-10, 2);
35  msgcounter[msgtype] = newpair;
36  goto tryagain;
37  }
38  (iter->second).first++;
39  if ((iter->second).first > 0)
40  {
41  if ((iter->second).first == (iter->second).second)
42  {
43  std::cout << *Message << err_message << std::endl;
44  (iter->second).first = 0;
45  (iter->second).second *= 2;
46  }
47  // else
48  // {
49  // cout << "Not sending " << (iter->second).first
50  // << ", 2nd: " << (iter->second).second
51  // << ", %: " << (iter->second).first%(iter->second).second << endl;
52  // }
53  }
54  else
55  {
56  std::cout << *Message << err_message << std::endl;
57  }
58  if (severity > MSG_SEV_INFORMATIONAL)
59  {
61  se->WriteLogFile(ThisName, err_message);
62  }
63  return 0;
64 }
65 
67 {
68  msgcounter.clear();
69  return 0;
70 }