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;
edm::messagedrop::StringProducerWithPhase::set
void set(std::string const &name, std::string const &label, unsigned int moduleID, const char *phase)
Definition: MessageDrop.cc:78
edm::MessageDrop::spSinglet
edm::propagate_const< messagedrop::StringProducerSinglet * > spSinglet
Definition: MessageDrop.h:79
edm::messagedrop::StringProducerWithPhase::idLabelMap_
std::map< unsigned int, std::string > idLabelMap_
Definition: MessageDrop.cc:94
edm::MessageDrop::warningAlwaysSuppressed
static bool warningAlwaysSuppressed
Definition: MessageDrop.h:74
edm::messagedrop::StringProducer
Definition: MessageDrop.cc:44
BTVHLTOfflineSource_cfi.pathname
pathname
Definition: BTVHLTOfflineSource_cfi.py:35
edm
HLT enums.
Definition: AlignableModifier.h:19
edm::max
EventID const & max(EventID const &lh, EventID const &rh)
Definition: EventID.h:118
edm::messagedrop::StringProducerSinglet::theContext
std::string theContext() const override
Definition: MessageDrop.cc:127
edm::messagedrop::StringProducerWithPhase::moduleID_
unsigned int moduleID_
Definition: MessageDrop.cc:90
CMS_SA_ALLOW
#define CMS_SA_ALLOW
Definition: thread_safety_macros.h:5
edm::messagedrop::StringProducer::theContext
virtual std::string theContext() const =0
edm::MessageDrop::infoAlwaysSuppressed
static bool infoAlwaysSuppressed
Definition: MessageDrop.h:72
edm::messagedrop::StringProducerWithPhase
Definition: MessageDrop.cc:50
edm::messagedrop::StringProducerPath::cache_
std::string cache_
Definition: MessageDrop.cc:121
edm::MessageDrop::moduleNameProducer
messagedrop::StringProducer const * moduleNameProducer
Definition: MessageDrop.h:80
edm::MessageDrop::setModuleWithPhase
void setModuleWithPhase(std::string const &name, std::string const &label, unsigned int moduleID, const char *phase)
Definition: MessageDrop.cc:155
edm::MessageDrop::clear
void clear()
Definition: MessageDrop.cc:174
edm::messagedrop::StringProducerSinglet
Definition: MessageDrop.cc:124
edm::messagedrop::StringProducerWithPhase::label_
std::string const * label_
Definition: MessageDrop.cc:88
edm::messagedrop::StringProducerPath::theContext
std::string theContext() const override
Definition: MessageDrop.cc:104
edm::MessageDrop::debugAlwaysSuppressed
static bool debugAlwaysSuppressed
Definition: MessageDrop.h:71
edm::MessageDrop::MessageDrop
MessageDrop()
Definition: MessageDrop.cc:136
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
edm::messagedrop::StringProducerPath::StringProducerPath
StringProducerPath()
Definition: MessageDrop.cc:99
SiPixelPI::phase
phase
Definition: SiPixelPayloadInspectorHelper.h:39
funct::true
true
Definition: Factorize.h:173
edm::MessageDrop::~MessageDrop
~MessageDrop()
Definition: MessageDrop.cc:149
edm::messagedrop::StringProducerPath::path_
std::string path_
Definition: MessageDrop.cc:119
MessageDrop.h
edm::messagedrop::StringProducerWithPhase::phasePtr_
const char * phasePtr_
Definition: MessageDrop.cc:89
edm::MessageDrop::spWithPhase
edm::propagate_const< messagedrop::StringProducerWithPhase * > spWithPhase
Definition: MessageDrop.h:77
SiStripPI::max
Definition: SiStripPayloadInspectorHelper.h:169
type
type
Definition: SiPixelVCal_PayloadInspector.cc:37
gainCalibHelper::gainCalibPI::type
type
Definition: SiPixelGainCalibHelper.h:39
thread_safety_macros.h
edm::messagedrop::StringProducerWithPhase::cache_
std::string cache_
Definition: MessageDrop.cc:93
createfilelist.int
int
Definition: createfilelist.py:10
edm::MessageDrop
Definition: MessageDrop.h:45
edm::MessageDrop::setSinglet
void setSinglet(const char *sing)
Definition: MessageDrop.cc:168
edm::MessageDrop::setPath
void setPath(const char *type, std::string const &pathname)
Definition: MessageDrop.cc:163
edm::messagedrop::StringProducerPath
Definition: MessageDrop.cc:97
edm::messagedrop::StringProducer::~StringProducer
virtual ~StringProducer()
Definition: MessageDrop.cc:46
edm::messagedrop::StringProducerSinglet::singlet_
const char * singlet_
Definition: MessageDrop.cc:131
edm::messagedrop::StringProducerSinglet::set
void set(const char *sing)
Definition: MessageDrop.cc:128
std
Definition: JetResolutionObject.h:76
edm::MessageDrop::instance
static MessageDrop * instance()
Definition: MessageDrop.cc:33
edm::MessageDrop::moduleContext
std::string moduleContext()
Definition: MessageDrop.cc:173
edm::MessageDrop::spPath
edm::propagate_const< messagedrop::StringProducerPath * > spPath
Definition: MessageDrop.h:78
Skims_PA_cff.name
name
Definition: Skims_PA_cff.py:17
edm::MessageDrop::jobMode
static std::string jobMode
Definition: MessageDrop.h:69
edm::messagedrop::StringProducerWithPhase::StringProducerWithPhase
StringProducerWithPhase()
Definition: MessageDrop.cc:52
edm::messagedrop::StringProducerPath::typePtr_
const char * typePtr_
Definition: MessageDrop.cc:118
edm::messagedrop::StringProducerWithPhase::theContext
std::string theContext() const override
Definition: MessageDrop.cc:60
edm::messagedrop::StringProducerWithPhase::name_
std::string const * name_
Definition: MessageDrop.cc:87
edm::MessageDrop::fwkInfoAlwaysSuppressed
static bool fwkInfoAlwaysSuppressed
Definition: MessageDrop.h:73
label
const char * label
Definition: PFTauDecayModeTools.cc:11
edm::messagedrop::StringProducerSinglet::StringProducerSinglet
StringProducerSinglet()
Definition: MessageDrop.cc:126
edm::messagedrop::StringProducerPath::set
void set(const char *type, std::string const &pathname)
Definition: MessageDrop.cc:111