Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:12:44

0001 #ifndef FWCore_MessageLogger_MessageLoggerQ_h
0002 #define FWCore_MessageLogger_MessageLoggerQ_h
0003 
0004 #include "FWCore/MessageLogger/interface/ELseverityLevel.h"
0005 #include "FWCore/Utilities/interface/thread_safety_macros.h"
0006 
0007 #include <memory>
0008 
0009 #include <string>
0010 #include <map>
0011 #include <set>
0012 
0013 namespace edm {
0014 
0015   // --- forward declarations:
0016   class ErrorObj;
0017   class ParameterSet;
0018   class ELdestination;
0019   namespace service {
0020     class AbstractMLscribe;
0021   }
0022 
0023   class MessageLoggerQ {
0024   public:
0025     MessageLoggerQ(MessageLoggerQ const&) = delete;
0026     void operator=(MessageLoggerQ const&) = delete;
0027 
0028     // --- enumerate types of messages that can be enqueued:
0029     enum OpCode  // abbrev's used hereinafter
0030     {
0031       END_THREAD  // END
0032       ,
0033       LOG_A_MESSAGE  // LOG
0034       ,
0035       CONFIGURE  // CFG -- handshaked
0036       ,
0037       EXTERN_DEST  // EXT
0038       ,
0039       SUMMARIZE  // SUM
0040       ,
0041       JOBMODE  // MOD
0042       ,
0043       SHUT_UP  // SHT
0044       ,
0045       FLUSH_LOG_Q  // FLS -- handshaked
0046       ,
0047       GROUP_STATS  // GRP
0048       ,
0049       FJR_SUMMARY  // JRS -- handshaked
0050     };             // OpCode
0051 
0052     // ---  birth via a surrogate:
0053     static MessageLoggerQ* instance();
0054 
0055     // ---  post a message to the queue:
0056     static void MLqEND();
0057     static void MLqLOG(ErrorObj* p);
0058     static void MLqCFG(ParameterSet* p);
0059     static void MLqSUM();
0060     static void MLqMOD(std::string* jm);
0061     static void MLqSHT();
0062     static void MLqFLS();
0063     static void MLqGRP(std::string* cat_p);
0064     static void MLqJRS(std::map<std::string, double>* sum_p);
0065 
0066     // ---  bookkeeping for single-thread mode
0067     static void setMLscribe_ptr(std::shared_ptr<edm::service::AbstractMLscribe> m);
0068 
0069     // ---  helper for scribes
0070     static bool handshaked(const OpCode& op);
0071 
0072     // --- special control of standAlone logging behavior
0073     static void standAloneThreshold(edm::messagelogger::ELseverityLevel const& severity);
0074     static void squelch(std::string const& category);
0075     static bool ignore(edm::messagelogger::ELseverityLevel const& severity, std::string const& category);
0076 
0077   private:
0078     // ---  traditional birth/death, but disallowed to users:
0079     MessageLoggerQ();
0080     ~MessageLoggerQ();
0081 
0082     // ---  place an item onto the queue, or execute the command directly
0083     static void simpleCommand(OpCode opcode, void* operand);
0084     static void handshakedCommand(OpCode opcode, void* operand, std::string const& commandMnemonic);
0085 
0086     // --- data:
0087     CMS_THREAD_SAFE static std::shared_ptr<edm::service::AbstractMLscribe> mlscribe_ptr;
0088     CMS_THREAD_SAFE static edm::messagelogger::ELseverityLevel threshold;
0089     CMS_THREAD_SAFE static std::set<std::string> squelchSet;
0090 
0091   };  // MessageLoggerQ
0092 
0093 }  // namespace edm
0094 
0095 #endif  // FWCore_MessageLogger_MessageLoggerQ_h