Line Code
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74
#include "FWCore/MessageLogger/interface/LoggedErrorsSummary.h"
#include "FWCore/MessageService/test/UnitTestClient_SLumi.h"
#include "FWCore/Framework/interface/MakerMacros.h"
#include "FWCore/Framework/interface/Event.h"

#include <iostream>
#include <string>

namespace edmtest {

  bool UTC_SL1::enableNotYetCalled = true;
  int UTC_SL1::n = 0;
  int UTC_SL2::n = 0;

  void UTC_SL1::analyze(edm::Event const& /*unused*/
                        ,
                        edm::EventSetup const& /*unused*/
  ) {
    if (enableNotYetCalled) {
      edm::EnableLoggedErrorsSummary();
      enableNotYetCalled = false;
    }
    n++;
    if (n <= 2)
      return;
    edm::LogError("cat_A") << "S1 with identifier " << identifier << " n = " << n;
    edm::LogError("grouped_cat") << "S1 timer with identifier " << identifier;
  }

  void UTC_SL2::analyze(edm::Event const& /*unused*/
                        ,
                        edm::EventSetup const& /*unused*/
  ) {
    n++;
    if (n <= 2)
      return;
    edm::LogError("cat_A") << "S2 with identifier " << identifier;
    edm::LogError("grouped_cat") << "S2 timer with identifier " << identifier;
    edm::LogError("cat_B") << "S2B with identifier " << identifier;
    for (int i = 0; i < n; ++i) {
      edm::LogError("cat_B") << "more S2B";
    }
  }

  void UTC_SLUMMARY::analyze(edm::Event const& iEvent, edm::EventSetup const& /*unused*/
  ) {
    auto const index = iEvent.streamID().value();
    if (!edm::FreshErrorsExist(index)) {
      edm::LogInfo("NoFreshErrors") << "Not in this event, anyway";
    }
    auto es = edm::LoggedErrorsSummary(index);
    std::ostringstream os;
    for (unsigned int i = 0; i != es.size(); ++i) {
      os << es[i].category << "   " << es[i].module << "   " << es[i].count << "\n";
    }
    edm::LogVerbatim("ErrorsInEvent") << os.str();
  }

  void UTC_SLUMMARY::endLuminosityBlock(edm::LuminosityBlock const& /*unused*/
                                        ,
                                        edm::EventSetup const& /*unused*/
  ) {
    // throw cms::Exception("endLuminosityBlock called!");
    edm::LogInfo("endLuminosityBlock") << "endLuminosityBlock() called";
  }

}  // namespace edmtest

using edmtest::UTC_SL1;
using edmtest::UTC_SL2;
using edmtest::UTC_SLUMMARY;
DEFINE_FWK_MODULE(UTC_SL1);
DEFINE_FWK_MODULE(UTC_SL2);
DEFINE_FWK_MODULE(UTC_SLUMMARY);