File indexing completed on 2023-03-17 11:03:15
0001 #include "FWCore/MessageLogger/interface/LoggedErrorsSummary.h"
0002 #include "FWCore/MessageService/test/UnitTestClient_SLumi.h"
0003 #include "FWCore/Framework/interface/MakerMacros.h"
0004 #include "FWCore/Framework/interface/Event.h"
0005
0006 #include <iostream>
0007 #include <string>
0008
0009 namespace edmtest {
0010
0011 bool UTC_SL1::enableNotYetCalled = true;
0012 int UTC_SL1::n = 0;
0013 int UTC_SL2::n = 0;
0014
0015 void UTC_SL1::analyze(edm::Event const&
0016 ,
0017 edm::EventSetup const&
0018 ) {
0019 if (enableNotYetCalled) {
0020 edm::EnableLoggedErrorsSummary();
0021 enableNotYetCalled = false;
0022 }
0023 n++;
0024 if (n <= 2)
0025 return;
0026 edm::LogError("cat_A") << "S1 with identifier " << identifier << " n = " << n;
0027 edm::LogError("grouped_cat") << "S1 timer with identifier " << identifier;
0028 }
0029
0030 void UTC_SL2::analyze(edm::Event const&
0031 ,
0032 edm::EventSetup const&
0033 ) {
0034 n++;
0035 if (n <= 2)
0036 return;
0037 edm::LogError("cat_A") << "S2 with identifier " << identifier;
0038 edm::LogError("grouped_cat") << "S2 timer with identifier " << identifier;
0039 edm::LogError("cat_B") << "S2B with identifier " << identifier;
0040 for (int i = 0; i < n; ++i) {
0041 edm::LogError("cat_B") << "more S2B";
0042 }
0043 }
0044
0045 void UTC_SLUMMARY::analyze(edm::Event const& iEvent, edm::EventSetup const&
0046 ) {
0047 auto const index = iEvent.streamID().value();
0048 if (!edm::FreshErrorsExist(index)) {
0049 edm::LogInfo("NoFreshErrors") << "Not in this event, anyway";
0050 }
0051 auto es = edm::LoggedErrorsSummary(index);
0052 std::ostringstream os;
0053 for (unsigned int i = 0; i != es.size(); ++i) {
0054 os << es[i].category << " " << es[i].module << " " << es[i].count << "\n";
0055 }
0056 edm::LogVerbatim("ErrorsInEvent") << os.str();
0057 }
0058
0059 void UTC_SLUMMARY::endLuminosityBlock(edm::LuminosityBlock const&
0060 ,
0061 edm::EventSetup const&
0062 ) {
0063
0064 edm::LogInfo("endLuminosityBlock") << "endLuminosityBlock() called";
0065 }
0066
0067 }
0068
0069 using edmtest::UTC_SL1;
0070 using edmtest::UTC_SL2;
0071 using edmtest::UTC_SLUMMARY;
0072 DEFINE_FWK_MODULE(UTC_SL1);
0073 DEFINE_FWK_MODULE(UTC_SL2);
0074 DEFINE_FWK_MODULE(UTC_SLUMMARY);