otsdaq  v2_05_02_indev
ITRACEController.h
1 #ifndef OTSDAQ_MESSAGEFACILITY_ITRACECONTROLLER_H
2 #define OTSDAQ_MESSAGEFACILITY_ITRACECONTROLLER_H
3 
4 #include <limits.h>
5 #include <unistd.h>
6 #include <deque>
7 #include <string>
8 #include <unordered_map>
9 
10 namespace ots
11 {
13 {
14  public:
15  struct TraceMasks
16  {
17  uint64_t M;
18  uint64_t S;
19  uint64_t T;
20  };
21  typedef std::unordered_map<std::string, TraceMasks> TraceLevelMap;
22  typedef std::unordered_map<std::string, TraceLevelMap> HostTraceLevelMap;
23 
24  ITRACEController() {}
25  virtual ~ITRACEController() = default;
26 
27  virtual HostTraceLevelMap GetTraceLevels() = 0;
28  virtual void SetTraceLevelMask(std::string trace_name, TraceMasks const& lvl, std::string host = "localhost") = 0;
29 
30  protected:
31  std::string GetHostnameString()
32  {
33  char hostname_c[HOST_NAME_MAX];
34  gethostname(hostname_c, HOST_NAME_MAX);
35  return std::string(hostname_c);
36  }
37 };
38 
40 {
41  public:
43  virtual ~NullTRACEController() = default;
44 
45  HostTraceLevelMap GetTraceLevels() final { return HostTraceLevelMap(); }
46  void SetTraceLevelMask(std::string, TraceMasks const&, std::string) final {}
47 };
48 
49 } // namespace ots
50 
51 #endif // OTSDAQ_MESSAGEFACILITY_ITRACECONTROLLER_H