otsdaq  v2_05_02_indev
TRACEController.cc
1 #include "otsdaq/MessageFacility/TRACEController.h"
2 #include "TRACE/trace.h"
3 
4 ots::ITRACEController::HostTraceLevelMap ots::TRACEController::GetTraceLevels()
5 {
6  TLOG(TLVL_DEBUG) << "Getting TRACE levels";
7 
8  HostTraceLevelMap output;
9  auto hostname = GetHostnameString();
10 
11  unsigned ee = traceControl_p->num_namLvlTblEnts;
12  for(unsigned ii = 0; ii < ee; ++ii)
13  {
14  if(traceNamLvls_p[ii].name[0])
15  {
16  std::string name = std::string(traceNamLvls_p[ii].name);
17  output[hostname][name].M = traceNamLvls_p[ii].M;
18  output[hostname][name].S = traceNamLvls_p[ii].S;
19  output[hostname][name].T = traceNamLvls_p[ii].T;
20  }
21  }
22  return output;
23 }
24 
25 void ots::TRACEController::SetTraceLevelMask(std::string name, TraceMasks const& lvl, std::string hostname)
26 {
27  if(hostname != "localhost" && hostname != GetHostnameString())
28  {
29  TLOG(TLVL_WARNING) << "TRACEController asked to set TRACE levels for host " << hostname << ", but this is " << GetHostnameString() << "!";
30  return;
31  }
32  TLOG(TLVL_DEBUG) << "Setting levels for name " << name << " to " << std::hex << std::showbase << lvl.M << " " << lvl.S << " " << lvl.T;
33  if(name != "ALL")
34  {
35  TRACE_CNTL("lvlmsknM", name.c_str(), lvl.M);
36  TRACE_CNTL("lvlmsknS", name.c_str(), lvl.S);
37  TRACE_CNTL("lvlmsknT", name.c_str(), lvl.T);
38  }
39  else
40  {
41  TRACE_CNTL("lvlmskMg", lvl.M);
42  TRACE_CNTL("lvlmskSg", lvl.S);
43  TRACE_CNTL("lvlmskTg", lvl.T);
44  }
45 }