CMS 3D CMS Logo

MessageDrop.cc
Go to the documentation of this file.
1 // -*- C++ -*-
2 //
3 // Package: MessageLogger
4 // Class : MessageDrop
5 //
6 // Implementation:
7 // <Notes on implementation>
8 //
9 // Original Author: M. Fischler and Jim Kowalkowsi
10 // Created: Tues Feb 14 16:38:19 CST 2006
11 //
12 
13 // system include files
14 #include <cstring>
15 #include <limits>
16 
17 // user include files
20 
21 using namespace edm;
22 
23 // The following are false at initialization (in case configure is not done)
24 // and are set true at the start of configure_ordinary_destinations,
25 // but are set false once a destination is thresholded to react to the
26 // corresponding severity:
32 
34  thread_local static MessageDrop s_drop{};
35  return &s_drop;
36 }
37 namespace {
38  const std::string kBlankString{" "};
39 }
40 
41 namespace edm {
42  namespace messagedrop {
43 
45  public:
46  virtual ~StringProducer() {}
47  virtual std::string theContext() const = 0;
48  };
49 
51  public:
53  : name_(&kBlankString),
54  label_(&kBlankString),
55  phasePtr_("(Startup)"),
56  moduleID_(std::numeric_limits<unsigned int>::max()),
57  cache_(),
58  idLabelMap_() {}
59 
60  std::string theContext() const override {
61  if (cache_.empty()) {
63  auto nameLableIter = idLabelMap_.find(moduleID_);
64  if (nameLableIter != idLabelMap_.end()) {
65  cache_.assign(nameLableIter->second);
66  cache_.append(phasePtr_);
67  return cache_;
68  }
69  }
70  cache_.assign(*name_);
71  cache_.append(":");
72  cache_.append(*label_);
74  cache_.append(phasePtr_);
75  }
76  return cache_;
77  }
78  void set(std::string const& name, std::string const& label, unsigned int moduleID, const char* phase) {
79  name_ = &name;
80  label_ = &label;
81  moduleID_ = moduleID;
82  phasePtr_ = phase;
83  cache_.clear();
84  }
85 
86  private:
89  const char* phasePtr_;
90  unsigned int moduleID_;
91 
92  //This class is only used within a thread local object
94  CMS_SA_ALLOW mutable std::map<unsigned int, std::string> idLabelMap_;
95  };
96 
98  public:
100  : typePtr_("PathNotYetEstablished") // change log 4
101  ,
102  path_(" "),
103  cache_() {}
104  std::string theContext() const override {
105  if (cache_.empty()) {
106  cache_.assign(typePtr_);
107  cache_.append(path_);
108  }
109  return cache_;
110  }
111  void set(const char* type, std::string const& pathname) {
112  typePtr_ = type;
113  path_ = pathname;
114  cache_.clear();
115  }
116 
117  private:
118  const char* typePtr_;
120  //This class is only used within a thread local object
122  };
123 
125  public:
126  StringProducerSinglet() : singlet_("(NoModuleName)") {}
127  std::string theContext() const override { return singlet_; }
128  void set(const char* sing) { singlet_ = sing; }
129 
130  private:
131  const char* singlet_;
132  };
133 
134  } // namespace messagedrop
135 
137  : runEvent("pre-events"),
138  streamID(std::numeric_limits<unsigned int>::max()),
139  debugEnabled(true),
140  infoEnabled(true),
141  fwkInfoEnabled(true),
142  warningEnabled(true),
143  errorEnabled(true),
144  spWithPhase(new messagedrop::StringProducerWithPhase),
145  spPath(new messagedrop::StringProducerPath),
146  spSinglet(new messagedrop::StringProducerSinglet),
147  moduleNameProducer(spSinglet) {}
148 
150  delete spSinglet.get();
151  delete spPath.get();
152  delete spWithPhase.get();
153  }
154 
156  std::string const& label,
157  unsigned int moduleID,
158  const char* phase) {
159  spWithPhase->set(name, label, moduleID, phase);
161  }
162 
163  void MessageDrop::setPath(const char* type, std::string const& pathname) {
164  spPath->set(type, pathname);
166  }
167 
168  void MessageDrop::setSinglet(const char* sing) {
169  spSinglet->set(sing);
171  }
172 
175 } // namespace edm
176 
177 unsigned char MessageDrop::messageLoggerScribeIsRunning = 0;
#define CMS_SA_ALLOW
std::map< unsigned int, std::string > idLabelMap_
Definition: MessageDrop.cc:94
void setModuleWithPhase(std::string const &name, std::string const &label, unsigned int moduleID, const char *phase)
Definition: MessageDrop.cc:155
static MessageDrop * instance()
Definition: MessageDrop.cc:33
static std::string jobMode
Definition: MessageDrop.h:69
messagedrop::StringProducer const * moduleNameProducer
Definition: MessageDrop.h:80
void setSinglet(const char *sing)
Definition: MessageDrop.cc:168
static bool debugAlwaysSuppressed
Definition: MessageDrop.h:71
char const * label
edm::propagate_const< messagedrop::StringProducerWithPhase * > spWithPhase
Definition: MessageDrop.h:77
edm::propagate_const< messagedrop::StringProducerSinglet * > spSinglet
Definition: MessageDrop.h:79
std::string theContext() const override
Definition: MessageDrop.cc:104
std::string moduleContext()
Definition: MessageDrop.cc:173
static bool warningAlwaysSuppressed
Definition: MessageDrop.h:74
edm::propagate_const< messagedrop::StringProducerPath * > spPath
Definition: MessageDrop.h:78
std::string theContext() const override
Definition: MessageDrop.cc:60
static bool fwkInfoAlwaysSuppressed
Definition: MessageDrop.h:73
HLT enums.
virtual std::string theContext() const =0
void setPath(const char *type, std::string const &pathname)
Definition: MessageDrop.cc:163
static bool infoAlwaysSuppressed
Definition: MessageDrop.h:72
std::string theContext() const override
Definition: MessageDrop.cc:127
EventID const & max(EventID const &lh, EventID const &rh)
Definition: EventID.h:118