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