Go to the documentation of this file.00001 #ifndef FWCore_MessageService_MessageLoggerScribe_h
00002 #define FWCore_MessageService_MessageLoggerScribe_h
00003
00004 #include "FWCore/Utilities/interface/value_ptr.h"
00005
00006 #include "FWCore/MessageService/interface/ELdestControl.h"
00007 #include "FWCore/MessageService/interface/MsgContext.h"
00008 #include "FWCore/MessageService/interface/MessageLoggerDefaults.h"
00009 #include "FWCore/MessageLogger/interface/MessageLoggerQ.h"
00010 #include "FWCore/MessageLogger/interface/AbstractMLscribe.h"
00011
00012 #include "FWCore/ParameterSet/interface/ParameterSet.h"
00013
00014 #include "boost/shared_ptr.hpp"
00015
00016 #include <iosfwd>
00017 #include <vector>
00018 #include <map>
00019
00020 #include <iostream>
00021
00022 namespace edm {
00023 namespace service {
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064
00065
00066
00067
00068
00069
00070
00071
00072
00073
00074
00075
00076
00077
00078
00079
00080
00081
00082 class ThreadQueue;
00083 class ErrorLog;
00084 class ELadministrator;
00085
00086 class MessageLoggerScribe : public AbstractMLscribe
00087 {
00088 public:
00089
00090
00091
00093 explicit MessageLoggerScribe(boost::shared_ptr<ThreadQueue> queue);
00094
00095 virtual ~MessageLoggerScribe();
00096
00097
00098 virtual
00099 void run();
00100 virtual
00101 void runCommand(MessageLoggerQ::OpCode opcode, void * operand);
00102
00103
00104
00105 static ErrorLog * getErrorLog_ptr() {return static_errorlog_p;}
00106
00107 private:
00108
00109 typedef std::string String;
00110 typedef std::vector<String> vString;
00111 typedef ParameterSet PSet;
00112
00113
00114 void log(ErrorObj * errorobj_p);
00115
00116
00117 void triggerStatisticsSummaries();
00118 void triggerFJRmessageSummary(std::map<std::string, double> & sm);
00119
00120
00121 void configure_errorlog( );
00122 void configure_fwkJobReports( );
00123 void configure_ordinary_destinations( );
00124 void configure_statistics( );
00125 void configure_dest( ELdestControl & dest_ctrl
00126 , String const & filename
00127 );
00128 void configure_default_fwkJobReport( ELdestControl & dest_ctrl);
00129 void configure_external_dests( );
00130
00131 #define VALIDATE_ELSEWHERE // ChangeLog 11
00132
00133 #ifdef OLDSTYLE
00134 template <class T>
00135 T getAparameter ( PSet const& p, std::string const & id, T const & def )
00136 {
00137 T t;
00138 try {
00139 t = p.template getUntrackedParameter<T>(id, def);
00140 } catch (...) {
00141 t = p.template getParameter<T>(id);
00142 std::cerr << "Tracked parameter " << id
00143 << " used in MessageLogger configuration.\n"
00144 << "Use of tracked parameters for the message service "
00145 << "is deprecated.\n"
00146 << "The .cfg file should be modified to make this untracked.\n";
00147 }
00148 return t;
00149 }
00150 #else
00151 #ifdef SIMPLESTYLE
00152 template <class T>
00153 T getAparameter ( PSet const& p, std::string const & id, T const & def )
00154 {
00155 T t;
00156 t = p.template getUntrackedParameter<T>(id, def);
00157 return t;
00158 }
00159 #else
00160 #ifdef VALIDATE_ELSEWHERE
00161 template <class T>
00162 T getAparameter ( PSet const& p, std::string const & id, T const & def )
00163 {
00164 T t = def;
00165 try {
00166 t = p.template getUntrackedParameter<T>(id, def);
00167 } catch (...) {
00168 try {
00169 t = p.template getParameter<T>(id);
00170 } catch (...) {
00171
00172
00173
00174 }
00175 }
00176 return t;
00177 }
00178 #else // Do not tolerate errors
00179 template <class T>
00180 T getAparameter ( PSet const& p, std::string const & id, T const & def )
00181 {
00182 T t;
00183 try {
00184 t = p.template getUntrackedParameter<T>(id, def);
00185 } catch (cms::Exception& e) {
00186 try {
00187 t = p.template getParameter<T>(id);
00188 } catch (...) {
00189
00190
00191 e.raise();
00192 }
00193 std::cerr << "Tracked parameter " << id
00194 << " used in MessageLogger configuration.\n"
00195 << "Use of tracked parameters for the message service "
00196 << "is not allowed.\n"
00197 << "The .cfg file should be modified to make this untracked.\n";
00198 e.raise();
00199 } catch (...) {
00200
00201 throw;
00202 }
00203 return t;
00204 }
00205
00206 #endif // VALIDATE_ELSEWHERE
00207 #endif // SIMPLESTYLE
00208 #endif // OLD_STYLE and the else Do not tolerate errors
00209
00210 #ifdef REMOVE
00211 template <class T>
00212 T getCategoryDefault ( PSet * p,
00213 std::string const & id,
00214 std::string const & def )
00215 {
00216 T t;
00217 t = p->template getUntrackedParameter<T>(id, def);
00218 return t;
00219 }
00220 #endif
00221
00222
00223
00224 void parseCategories (std::string const & s, std::vector<std::string> & cats);
00225 void setStaticErrorLog_ptr() {static_errorlog_p = errorlog_p.get();}
00226
00227
00228 ELadministrator * admin_p;
00229 ELdestControl early_dest;
00230 boost::shared_ptr<ErrorLog> errorlog_p;
00231 std::vector<boost::shared_ptr<std::ofstream> > file_ps;
00232 MsgContext msg_context;
00233 boost::shared_ptr<PSet> job_pset_p;
00234 std::vector<NamedDestination *> extern_dests;
00235 std::map<String,std::ostream *> stream_ps;
00236 std::vector<String> ordinary_destination_filenames;
00237 std::vector<ELdestControl> statisticsDestControls;
00238 std::vector<bool> statisticsResets;
00239 std::string jobReportOption;
00240 static ErrorLog * static_errorlog_p;
00241 bool clean_slate_configuration;
00242 value_ptr<MessageLoggerDefaults> messageLoggerDefaults;
00243 bool active;
00244 bool singleThread;
00245 bool done;
00246 bool purge_mode;
00247 int count;
00248 boost::shared_ptr<ThreadQueue> m_queue;
00249
00250 };
00251
00252
00253 }
00254 }
00255
00256
00257 #endif // FWCore_MessageService_MessageLoggerScribe_h