00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045 #include "FWCore/ParameterSet/interface/ParameterSet.h"
00046
00047 #include "FWCore/MessageService/interface/MessageLogger.h"
00048
00049 #include "FWCore/MessageLogger/interface/MessageLoggerQ.h"
00050 #include "FWCore/MessageLogger/interface/MessageDrop.h"
00051
00052 #include "DataFormats/Provenance/interface/ModuleDescription.h"
00053
00054 #include "FWCore/MessageLogger/interface/JobReport.h"
00055 #include "FWCore/ServiceRegistry/interface/Service.h"
00056
00057 #include <sstream>
00058 #include <string>
00059 #include <map>
00060
00061 static const std::string kPostModule("PostModule");
00062 static const std::string kSource("main_input:source");
00063
00064 using namespace edm;
00065 using namespace edm::service;
00066
00067 namespace edm {
00068 namespace service {
00069
00070 bool edm::service::MessageLogger::anyDebugEnabled_ = false;
00071 bool edm::service::MessageLogger::everyDebugEnabled_ = false;
00072 bool edm::service::MessageLogger::fjrSummaryRequested_ = false;
00073
00074
00075
00076
00077 edm::service::MessageLogger::
00078 MessageLogger( ParameterSet const & iPS
00079 , ActivityRegistry & iRegistry
00080 )
00081 : curr_module_("BeginningJob")
00082 , debugEnabled_(false)
00083 {
00084
00085 fjrSummaryRequested_ =
00086 iPS.getUntrackedParameter<bool>("messageSummaryToJobReport", false);
00087
00088 typedef std::vector<std::string> vString;
00089 vString empty_vString;
00090
00091
00092 vString debugModules;
00093 debugModules =
00094 iPS.getUntrackedParameter<vString>("debugModules", empty_vString);
00095
00096
00097 vString suppressDebug;
00098 suppressDebug =
00099 iPS.getUntrackedParameter<vString>("suppressDebug", empty_vString);
00100
00101 vString suppressInfo;
00102 suppressInfo =
00103 iPS.getUntrackedParameter<vString>("suppressInfo", empty_vString);
00104
00105 vString suppressWarning;
00106 suppressWarning =
00107 iPS.getUntrackedParameter<vString>("suppressWarning", empty_vString);
00108
00109
00110
00111
00112 for( vString::const_iterator it = suppressDebug.begin();
00113 it != suppressDebug.end(); ++it ) {
00114 suppression_levels_[*it] = ELseverityLevel::ELsev_success;
00115 }
00116
00117 for( vString::const_iterator it = suppressInfo.begin();
00118 it != suppressInfo.end(); ++it ) {
00119 suppression_levels_[*it] = ELseverityLevel::ELsev_info;
00120 }
00121
00122 for( vString::const_iterator it = suppressWarning.begin();
00123 it != suppressWarning.end(); ++it ) {
00124 suppression_levels_[*it] = ELseverityLevel::ELsev_warning;
00125 }
00126
00127
00128
00129 if ( debugModules.empty()) {
00130 MessageDrop::instance()->debugEnabled = false;
00131 } else {
00132 anyDebugEnabled_ = true;
00133 MessageDrop::instance()->debugEnabled = true;
00134
00135 }
00136
00137 if ( debugModules.empty()) anyDebugEnabled_ = true;
00138 for( vString::const_iterator it = debugModules.begin();
00139 it != debugModules.end(); ++it ) {
00140 if (*it == "*") {
00141 everyDebugEnabled_ = true;
00142 } else {
00143 debugEnabledModules_.insert(*it);
00144 }
00145 }
00146
00147
00148 std::string jr_name = edm::MessageDrop::instance()->jobreport_name;
00149 if (!jr_name.empty()) {
00150 std::string * jr_name_p = new std::string(jr_name);
00151 MessageLoggerQ::MLqJOB( jr_name_p );
00152 }
00153
00154
00155 std::string jm = edm::MessageDrop::instance()->jobMode;
00156 std::string * jm_p = new std::string(jm);
00157 MessageLoggerQ::MLqMOD( jm_p );
00158
00159 MessageLoggerQ::MLqCFG( new ParameterSet(iPS) );
00160
00161 iRegistry.watchPostBeginJob(this,&MessageLogger::postBeginJob);
00162 iRegistry.watchPostEndJob(this,&MessageLogger::postEndJob);
00163
00164 iRegistry.watchPreModuleConstruction(this,&MessageLogger::preModuleConstruction);
00165 iRegistry.watchPostModuleConstruction(this,&MessageLogger::postModuleConstruction);
00166
00167
00168 iRegistry.watchPreSourceConstruction(this,&MessageLogger::preSourceConstruction);
00169 iRegistry.watchPostSourceConstruction(this,&MessageLogger::postSourceConstruction);
00170
00171
00172 iRegistry.watchPreProcessEvent(this,&MessageLogger::preEventProcessing);
00173 iRegistry.watchPostProcessEvent(this,&MessageLogger::postEventProcessing);
00174
00175 iRegistry.watchPreModule(this,&MessageLogger::preModule);
00176 iRegistry.watchPostModule(this,&MessageLogger::postModule);
00177
00178 iRegistry.watchPreSource(this,&MessageLogger::preSource);
00179 iRegistry.watchPostSource(this,&MessageLogger::postSource);
00180
00181 }
00182
00183
00184
00185
00186
00187
00188
00189
00190
00191
00192
00193
00194
00195
00196
00197
00198
00199
00200
00201
00202
00203
00204
00205
00206
00207
00208
00209
00210 void
00211 MessageLogger::postBeginJob()
00212 {
00213 MessageDrop::instance()->runEvent = "BeforeEvents";
00214 MessageDrop::instance()->moduleName = "";
00215 }
00216
00217 void
00218 MessageLogger::postEndJob()
00219 {
00220 SummarizeInJobReport();
00221 MessageLoggerQ::MLqSUM ( );
00222 }
00223
00224 void
00225 MessageLogger::preEventProcessing( const edm::EventID& iID
00226 , const edm::Timestamp& iTime
00227 )
00228 {
00229 std::ostringstream ost;
00230 curr_event_ = iID;
00231 ost << "Run: " << curr_event_.run()
00232 << " Event: " << curr_event_.event();
00233 edm::MessageDrop::instance()->runEvent = ost.str();
00234 }
00235 void
00236 MessageLogger::postEventProcessing(const Event&, const EventSetup&)
00237 {
00238
00239 }
00240
00241 void
00242 MessageLogger::preSourceConstruction(const ModuleDescription& desc)
00243 {
00244 curr_module_ = desc.moduleName_;
00245 curr_module_ += ":";
00246 curr_module_ += desc.moduleLabel_;
00247 MessageDrop::instance()->moduleName = curr_module_ + "{*ctor*}";
00248 if (!anyDebugEnabled_) {
00249 MessageDrop::instance()->debugEnabled = false;
00250 } else if (everyDebugEnabled_) {
00251 MessageDrop::instance()->debugEnabled = true;
00252 } else {
00253 MessageDrop::instance()->debugEnabled =
00254 debugEnabledModules_.count(desc.moduleLabel_);
00255 }
00256 }
00257
00258 void
00259 MessageLogger::preSource()
00260 {
00261 MessageDrop* messageDrop = MessageDrop::instance();
00262 curr_module_ = kSource;
00263
00264
00265 messageDrop->moduleName = curr_module_;
00266 if (!anyDebugEnabled_) {
00267 messageDrop->debugEnabled = false;
00268 } else if (everyDebugEnabled_) {
00269 messageDrop->debugEnabled = true;
00270 } else {
00271 messageDrop->debugEnabled =
00272 debugEnabledModules_.count("source");
00273 }
00274 std::map<const std::string,ELseverityLevel>::const_iterator it =
00275 suppression_levels_.find("source");
00276 if ( it != suppression_levels_.end() ) {
00277 messageDrop->debugEnabled = messageDrop->debugEnabled
00278 && (it->second < ELseverityLevel::ELsev_success );
00279 messageDrop->infoEnabled = (it->second < ELseverityLevel::ELsev_info );
00280 messageDrop->warningEnabled = (it->second < ELseverityLevel::ELsev_warning );
00281 } else {
00282 messageDrop->infoEnabled = true;
00283 messageDrop->warningEnabled = true;
00284 }
00285
00286 }
00287
00288
00289 void
00290 MessageLogger::preModuleConstruction(const ModuleDescription& desc)
00291 {
00292
00293 curr_module_ = desc.moduleName_;
00294 curr_module_ += ":";
00295 curr_module_ += desc.moduleLabel_;
00296
00297 MessageDrop::instance()->moduleName = curr_module_ + "{ctor}";
00298 if (!anyDebugEnabled_) {
00299 MessageDrop::instance()->debugEnabled = false;
00300 } else if (everyDebugEnabled_) {
00301 MessageDrop::instance()->debugEnabled = true;
00302 } else {
00303 MessageDrop::instance()->debugEnabled =
00304 debugEnabledModules_.count(desc.moduleLabel_);
00305 }
00306 }
00307
00308 void
00309 MessageLogger::preModule(const ModuleDescription& desc)
00310 {
00311
00312
00313 MessageDrop* messageDrop = MessageDrop::instance();
00314 std::map<const ModuleDescription*,std::string>::const_iterator itFind = descToCalcName_.find(&desc);
00315 if ( itFind == descToCalcName_.end()) {
00316 curr_module_ = desc.moduleName_;
00317 curr_module_ += ":";
00318 curr_module_ += desc.moduleLabel_;
00319
00320 descToCalcName_[&desc]=curr_module_;
00321 messageDrop->moduleName = curr_module_;
00322 } else {
00323 messageDrop->moduleName = itFind->second;
00324 }
00325
00326 if (!anyDebugEnabled_) {
00327 messageDrop->debugEnabled = false;
00328 } else if (everyDebugEnabled_) {
00329 messageDrop->debugEnabled = true;
00330 } else {
00331 messageDrop->debugEnabled =
00332 debugEnabledModules_.count(desc.moduleLabel_);
00333 }
00334
00335 std::map<const std::string,ELseverityLevel>::const_iterator it =
00336 suppression_levels_.find(desc.moduleLabel_);
00337 if ( it != suppression_levels_.end() ) {
00338 messageDrop->debugEnabled = messageDrop->debugEnabled
00339 && (it->second < ELseverityLevel::ELsev_success );
00340 messageDrop->infoEnabled = (it->second < ELseverityLevel::ELsev_info );
00341 messageDrop->warningEnabled = (it->second < ELseverityLevel::ELsev_warning );
00342 } else {
00343 messageDrop->infoEnabled = true;
00344 messageDrop->warningEnabled = true;
00345 }
00346 }
00347
00348 void
00349 MessageLogger::postSourceConstruction(const ModuleDescription& iDescription)
00350 {
00351
00352
00353 curr_module_ = "AfterSourceConstruction";
00354 MessageDrop::instance()->moduleName = curr_module_;
00355 }
00356
00357 void
00358 MessageLogger::postModuleConstruction(const ModuleDescription& iDescription)
00359 {
00360
00361
00362 curr_module_ = "AfterModuleConstruction";
00363 MessageDrop::instance()->moduleName = curr_module_;
00364 }
00365
00366 void
00367 MessageLogger::postSource()
00368 {
00369
00370
00371 curr_module_ = "PostSource";
00372 MessageDrop::instance()->moduleName = curr_module_;
00373 }
00374
00375 void
00376 MessageLogger::postModule(const ModuleDescription& iDescription)
00377 {
00378
00379
00380
00381
00382 MessageDrop::instance()->moduleName = kPostModule;
00383 }
00384
00385 void
00386 MessageLogger::SummarizeInJobReport() {
00387 if ( fjrSummaryRequested_ ) {
00388 std::map<std::string, double> * smp = new std::map<std::string, double> ();
00389 MessageLoggerQ::MLqJRS ( smp );
00390 Service<JobReport> reportSvc;
00391 reportSvc->reportMessageInfo(*smp);
00392 delete smp;
00393 }
00394 }
00395
00396 }
00397 }