CMS 3D CMS Logo

MessageLoggerQ.cc
Go to the documentation of this file.
6 
7 #include <cstring>
8 #include <iostream>
9 
11 //
12 // DO NOT replace the internal memcpy() calls by assignment or by
13 // any other form of copying unless you first understand in depth
14 // all of the alignment issues involved
15 //
17 
18 // Change Log
19 //
20 // 1 - 3/9/07 mf
21 // Addition of JOB command, to be used by --jobreport
22 // 2 - 6/19/07 mf
23 // Addition of MOD command, to be used by --mode
24 // 3 - 7/24/07 mf
25 // Addition of SHT command, to be used when no .cfg file was given
26 // 4 - 7/25/07 mf
27 // Change of each mommand function to start with MLq, e.g. MLqLOG
28 // 5 - 8/7/07 mf
29 // Addition of FLS command, to be used by FlushMessageLog
30 // 6 - 8/16/07 mf
31 // Addition of GRP command, to be used by GroupLogStatistics
32 // 7 - 6/18/08 mf
33 // Addition of JRS command, to be used by SummarizeInJobReport
34 // 8 - 10/24/08 mf
35 // Support for singleThread
36 // 9 - 8/6/09 mf
37 // handshaked() method to support cleaner abstraction of scribes
38 // 10 - 8/7/09 mf, crj
39 // major down-functioning: the actual dealing with buffer of the
40 // SingleConsumerQ is moved off into MainThreadMLscribe.
41 // 11 - 8/10/09 mf, cdj
42 // StandAloneScribe - a class that gets installed as the scribe if
43 // no presence is created at all. Enables easy stand-alone use of the
44 // logger
45 // 12 - 8/10/09 mf, cdj
46 // Removal of use of singleThread from this class - does not need it any
47 // longer
48 // 13 - 8/10/09 mf
49 // Special control of standAlone message logging
50 // 14 - 8/12/09 mf, cdj
51 // Better ownership management of standAlone or other scribe
52 
53 using namespace edm;
54 
55 // ChangeLog 11
56 namespace {
57  class StandAloneScribe : public edm::service::AbstractMLscribe {
58  public:
59  StandAloneScribe() {}
60 
61  // ---------- member functions ---------------------------
62 
63  void runCommand(edm::MessageLoggerQ::OpCode opcode, void *operand) override;
64 
65  private:
66  StandAloneScribe(const StandAloneScribe &) = delete; // stop default
67 
68  const StandAloneScribe &operator=(const StandAloneScribe &) = delete; // stop default
69 
70  // ---------- member data --------------------------------
71  };
72 
73  void StandAloneScribe::runCommand(edm::MessageLoggerQ::OpCode opcode, void *operand) {
74  //even though we don't print, have to clean up memory
75  switch (opcode) {
77  edm::ErrorObj *errorobj_p = static_cast<edm::ErrorObj *>(operand);
78  if (MessageLoggerQ::ignore // ChangeLog 13
79  (errorobj_p->xid().severity, errorobj_p->xid().id)) {
80  delete errorobj_p;
81  break;
82  }
83  if (errorobj_p->is_verbatim()) {
84  std::cerr << errorobj_p->fullText() << std::endl;
85  } else {
86  std::cerr << "%MSG" << errorobj_p->xid().severity.getSymbol() << " " << errorobj_p->xid().id << ": \n"
87  << errorobj_p->fullText() << "\n"
88  << "%MSG" << std::endl;
89  }
90  delete errorobj_p;
91  break;
92  }
95  std::string *string_p = static_cast<std::string *>(operand);
96  delete string_p;
97  break;
98  }
99  default:
100  break;
101  }
102  }
103 
104  // Changelog 14
105  std::shared_ptr<StandAloneScribe> obtainStandAloneScribePtr() {
106  static auto standAloneScribe_ptr = std::make_shared<StandAloneScribe>();
107  return standAloneScribe_ptr;
108  }
109 
110 } // end of anonymous namespace
111 
112 std::shared_ptr<edm::service::AbstractMLscribe> MessageLoggerQ::mlscribe_ptr = obtainStandAloneScribePtr();
113 // changeLog 8, 11, 14
114 
116 
118 
121  return &queue;
122 } // MessageLoggerQ::instance()
123 
124 void MessageLoggerQ::setMLscribe_ptr(std::shared_ptr<edm::service::AbstractMLscribe> m) // changeLog 8, 14
125 {
126  if (!m) {
127  mlscribe_ptr = obtainStandAloneScribePtr();
128  } else {
129  mlscribe_ptr = m;
130  }
131 } // MessageLoggerQ::setMLscribe_ptr(m)
132 
133 void MessageLoggerQ::simpleCommand(OpCode opcode, void *operand) // changeLog 8, 10
134 {
135  mlscribe_ptr->runCommand(opcode, operand);
136 } // simpleCommand
137 
139  void *operand,
140  std::string const &commandMnemonic) { // Change Log 10
141  try {
142  mlscribe_ptr->runCommand(opcode, operand);
143  } catch (edm::Exception &ex) {
144  ex << "\n The preceding exception was thrown in MessageLoggerScribe\n";
145  ex << "and forwarded to the main thread from the Messages thread.";
146  std::cerr << "exception from MessageLoggerQ::" << commandMnemonic << " - exception what() is \n" << ex.what();
147  // TODO - get the above text into the what itself
148  throw ex;
149  }
150 } // handshakedCommand
151 
152 void MessageLoggerQ::MLqEND() { simpleCommand(END_THREAD, (void *)nullptr); } // MessageLoggerQ::END()
153 
154 void MessageLoggerQ::MLqSHT() { simpleCommand(SHUT_UP, (void *)nullptr); } // MessageLoggerQ::SHT()
155 
157  simpleCommand(LOG_A_MESSAGE, static_cast<void *>(p));
158 } // MessageLoggerQ::LOG()
159 
160 void MessageLoggerQ::MLqCFG(ParameterSet *p) { handshakedCommand(CONFIGURE, p, "CFG"); } // MessageLoggerQ::CFG()
161 
162 void MessageLoggerQ::MLqSUM() { simpleCommand(SUMMARIZE, nullptr); } // MessageLoggerQ::SUM()
163 
165  simpleCommand(JOBMODE, static_cast<void *>(jm));
166 } // MessageLoggerQ::MOD()
167 
168 void MessageLoggerQ::MLqFLS() // Change Log 5
169 {
170  // The ConfigurationHandshake, developed for synchronous CFG, contains a
171  // place to convey exception information. FLS does not need this, nor does
172  // it need the parameter set, but we are reusing ConfigurationHandshake
173  // rather than reinventing the mechanism.
174  handshakedCommand(FLUSH_LOG_Q, nullptr, "FLS");
175 } // MessageLoggerQ::FLS()
176 
177 void MessageLoggerQ::MLqGRP(std::string *cat_p) // Change Log 6
178 {
179  simpleCommand(GROUP_STATS, static_cast<void *>(cat_p));
180 } // MessageLoggerQ::GRP()
181 
182 void MessageLoggerQ::MLqJRS(std::map<std::string, double> *sum_p) {
183  handshakedCommand(FJR_SUMMARY, sum_p, "JRS");
184 } // MessageLoggerQ::CFG()
185 
187 {
188  return ((op == CONFIGURE) || (op == FLUSH_LOG_Q) || (op == FJR_SUMMARY));
189 } // MessageLoggerQ::handshaked(op)
190 
191 // change Log 13:
193 std::set<std::string> MessageLoggerQ::squelchSet;
197  if (severity < threshold)
198  return true;
199  if (squelchSet.count(category) > 0)
200  return true;
201  return false;
202 }
edm::MessageLoggerQ::squelchSet
static std::set< std::string > squelchSet
Definition: MessageLoggerQ.h:88
edm::MessageLoggerQ::ignore
static bool ignore(edm::messagelogger::ELseverityLevel const &severity, std::string const &category)
Definition: MessageLoggerQ.cc:196
edm::MessageLoggerQ::MLqCFG
static void MLqCFG(ParameterSet *p)
Definition: MessageLoggerQ.cc:160
taus_updatedMVAIds_cff.category
category
Definition: taus_updatedMVAIds_cff.py:31
edm::MessageLoggerQ::SHUT_UP
Definition: MessageLoggerQ.h:42
edm::service::AbstractMLscribe
Definition: AbstractMLscribe.h:9
edm::MessageLoggerQ::instance
static MessageLoggerQ * instance()
Definition: MessageLoggerQ.cc:119
edm::MessageLoggerQ::squelch
static void squelch(std::string const &category)
Definition: MessageLoggerQ.cc:195
edm::MessageLoggerQ::MLqSUM
static void MLqSUM()
Definition: MessageLoggerQ.cc:162
edm::MessageLoggerQ::FLUSH_LOG_Q
Definition: MessageLoggerQ.h:44
edm::MessageLoggerQ::handshakedCommand
static void handshakedCommand(OpCode opcode, void *operand, std::string const &commandMnemonic)
Definition: MessageLoggerQ.cc:138
edm
HLT enums.
Definition: AlignableModifier.h:19
AlCaHLTBitMon_ParallelJobs.p
p
Definition: AlCaHLTBitMon_ParallelJobs.py:153
edm::ErrorObj
Definition: ErrorObj.h:43
ErrorObj.h
edm::MessageLoggerQ::MLqLOG
static void MLqLOG(ErrorObj *p)
Definition: MessageLoggerQ.cc:156
edm::MessageLoggerQ::CONFIGURE
Definition: MessageLoggerQ.h:34
cms::Exception::what
char const * what() const noexcept override
Definition: Exception.cc:103
edm::Exception
Definition: EDMException.h:77
edm::MessageLoggerQ::handshaked
static bool handshaked(const OpCode &op)
Definition: MessageLoggerQ.cc:186
EDMException.h
edm::ErrorObj::fullText
std::string fullText() const
Definition: ErrorObj.cc:151
edm::MessageLoggerQ::END_THREAD
Definition: MessageLoggerQ.h:30
edm::ELextendedID::severity
messagelogger::ELseverityLevel severity
Definition: ELextendedID.h:30
visualization-live-secondInstance_cfg.m
m
Definition: visualization-live-secondInstance_cfg.py:72
edm::MessageLoggerQ::setMLscribe_ptr
static void setMLscribe_ptr(std::shared_ptr< edm::service::AbstractMLscribe > m)
Definition: MessageLoggerQ.cc:124
edm::MessageLoggerQ::MLqSHT
static void MLqSHT()
Definition: MessageLoggerQ.cc:154
edm::MessageLoggerQ::MessageLoggerQ
MessageLoggerQ()
Definition: MessageLoggerQ.cc:115
MessageLoggerQ.h
edm::MessageLoggerQ::standAloneThreshold
static void standAloneThreshold(edm::messagelogger::ELseverityLevel const &severity)
Definition: MessageLoggerQ.cc:194
edm::MessageLoggerQ::MLqFLS
static void MLqFLS()
Definition: MessageLoggerQ.cc:168
edm::MessageLoggerQ::GROUP_STATS
Definition: MessageLoggerQ.h:46
CMS_THREAD_SAFE
#define CMS_THREAD_SAFE
Definition: thread_safety_macros.h:4
edm::messagelogger::ELseverityLevel::getSymbol
const std::string & getSymbol() const
Definition: ELseverityLevel.cc:87
edm::ErrorObj::xid
const ELextendedID & xid() const
Definition: ErrorObj.cc:142
createBeamHaloJobs.queue
queue
Definition: createBeamHaloJobs.py:343
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
AbstractMLscribe.h
edm::messagelogger::ELseverityLevel::ELsev_warning
Definition: ELseverityLevel.h:37
edm::ParameterSet
Definition: ParameterSet.h:47
edm::MessageLoggerQ::MLqGRP
static void MLqGRP(std::string *cat_p)
Definition: MessageLoggerQ.cc:177
thread_safety_macros.h
edm::MessageLoggerQ::threshold
static edm::messagelogger::ELseverityLevel threshold
Definition: MessageLoggerQ.h:87
edm::MessageLoggerQ::FJR_SUMMARY
Definition: MessageLoggerQ.h:48
edm::MessageLoggerQ::MLqMOD
static void MLqMOD(std::string *jm)
Definition: MessageLoggerQ.cc:164
edm::ELextendedID::id
std::string id
Definition: ELextendedID.h:29
edm::MessageLoggerQ::mlscribe_ptr
static std::shared_ptr< edm::service::AbstractMLscribe > mlscribe_ptr
Definition: MessageLoggerQ.h:86
edm::MessageLoggerQ::LOG_A_MESSAGE
Definition: MessageLoggerQ.h:32
ErrorSummaryFilter_cfi.severity
severity
Definition: ErrorSummaryFilter_cfi.py:5
edm::MessageLoggerQ::JOBMODE
Definition: MessageLoggerQ.h:40
edm::MessageLoggerQ
Definition: MessageLoggerQ.h:23
edm::messagelogger::ELseverityLevel
Definition: ELseverityLevel.h:26
edm::MessageLoggerQ::SUMMARIZE
Definition: MessageLoggerQ.h:38
edm::MessageLoggerQ::MLqEND
static void MLqEND()
Definition: MessageLoggerQ.cc:152
EcnaPython_AdcPeg12_S1_10_R170298_1_0_150_Dee0.cerr
cerr
Definition: EcnaPython_AdcPeg12_S1_10_R170298_1_0_150_Dee0.py:8
edm::MessageLoggerQ::~MessageLoggerQ
~MessageLoggerQ()
Definition: MessageLoggerQ.cc:117
edm::MessageLoggerQ::simpleCommand
static void simpleCommand(OpCode opcode, void *operand)
Definition: MessageLoggerQ.cc:133
edm::MessageLoggerQ::MLqJRS
static void MLqJRS(std::map< std::string, double > *sum_p)
Definition: MessageLoggerQ.cc:182
edm::MessageLoggerQ::OpCode
OpCode
Definition: MessageLoggerQ.h:29
edm::ErrorObj::is_verbatim
bool is_verbatim() const
Definition: ErrorObj.cc:147