CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
ThreadSafeLogMessageLoggerScribe.h
Go to the documentation of this file.
1 #ifndef FWCore_MessageService_ThreadSafeLogMessageLoggerScribe_h
2 #define FWCore_MessageService_ThreadSafeLogMessageLoggerScribe_h
3 
6 
11 
13 
14 #include <memory>
15 
16 #include <iosfwd>
17 #include <vector>
18 #include <map>
19 
20 #include <iostream>
21 #include <atomic>
22 #include "tbb/concurrent_queue.h"
23 
24 namespace edm {
25 namespace service {
26 
27 // ----------------------------------------------------------------------
28 //
29 // ThreadSafeLogMessageLoggerScribe.h
30 //
31 // OpCodeLOG_A_MESSAGE messages can be handled from multiple threads
32 //
33 // -----------------------------------------------------------------------
34 
35 class ThreadQueue;
36 class ELadministrator;
37 
39 {
40 public:
41  // --- birth/death:
42 
43  // ChangeLog 12
46 
48 
49  // --- receive and act on messages:
50  virtual // changelog 10
51  void runCommand(MessageLoggerQ::OpCode opcode, void * operand);
52  // changeLog 9
53 
54 private:
55  // --- convenience typedefs
57  typedef std::vector<String> vString;
58  typedef ParameterSet PSet;
59 
60  // --- log one consumed message
61  void log(ErrorObj * errorobj_p);
62 
63  // --- cause statistics destinations to output
65  void triggerFJRmessageSummary(std::map<std::string, double> & sm);
66 
67  // --- handle details of configuring via a ParameterSet:
68  void configure_errorlog( );
69  void configure_ordinary_destinations( ); // Change Log 3
70  void configure_statistics( ); // Change Log 3
71  void configure_dest( ELdestControl & dest_ctrl
72  , String const & filename
73  );
75 
76  template <class T> // ChangeLog 11
77  T getAparameter ( PSet const& p, std::string const & id, T const & def )
78  {
79  T t = def;
80  try {
81  t = p.template getUntrackedParameter<T>(id, def);
82  } catch (...) {
83  try {
84  t = p.template getParameter<T>(id);
85  } catch (...) {
86  // Since PSetValidation will catch such errors, we simply proceed as
87  // best we can in case we are setting up the logger just to contain the
88  // validation-caught error messages.
89  }
90  }
91  return t;
92  }
93 
94  // --- other helpers
95  void parseCategories (std::string const & s, std::vector<std::string> & cats);
96 
97  // --- data:
100  std::vector<edm::propagate_const<std::shared_ptr<std::ofstream>>> file_ps;
102  std::vector<NamedDestination *> extern_dests;
103  std::map<String, edm::propagate_const<std::ostream*>> stream_ps;
104  std::vector<String> ordinary_destination_filenames;
105  std::vector<ELdestControl> statisticsDestControls;
106  std::vector<bool> statisticsResets;
109  bool active;
110  std::atomic<bool> purge_mode; // changeLog 9
111  std::atomic<int> count; // changeLog 9
112  std::atomic<bool> m_messageBeingSent;
113  tbb::concurrent_queue<ErrorObj*> m_waitingMessages;
114 
115 }; // ThreadSafeLogMessageLoggerScribe
116 
117 
118 } // end of namespace service
119 } // namespace edm
120 
121 
122 #endif // FWCore_MessageService_ThreadSafeLogMessageLoggerScribe_h
std::vector< edm::propagate_const< std::shared_ptr< std::ofstream > > > file_ps
virtual void runCommand(MessageLoggerQ::OpCode opcode, void *operand)
void configure_dest(ELdestControl &dest_ctrl, String const &filename)
void triggerFJRmessageSummary(std::map< std::string, double > &sm)
T getAparameter(PSet const &p, std::string const &id, T const &def)
ThreadSafeLogMessageLoggerScribe()
— If queue is NULL, this sets singleThread true
std::map< String, edm::propagate_const< std::ostream * > > stream_ps
edm::propagate_const< std::shared_ptr< PSet > > job_pset_p
edm::propagate_const< std::shared_ptr< ELadministrator > > admin_p
tuple filename
Definition: lut2db_cfg.py:20
void parseCategories(std::string const &s, std::vector< std::string > &cats)
long double T
JetCorrectorParameters::Definitions def
Definition: classes.h:6