Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:12:48

0001 // Tests effect of LogFlush by cfg-configurable choices of how many
0002 // messages to use to clog the queue and whether or not FlushMessageLog
0003 // is invoked.  Under normal testing, it will invoke FlushMessageLog in
0004 // a situation where its absence would result in different output.
0005 
0006 #include "FWCore/Framework/interface/Frameworkfwd.h"
0007 #include "FWCore/Framework/interface/global/EDAnalyzer.h"
0008 #include "FWCore/Framework/interface/MakerMacros.h"
0009 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0010 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0011 
0012 #include <string>
0013 
0014 namespace edmtest {
0015 
0016   class UnitTestClient_P : public edm::global::EDAnalyzer<> {
0017   public:
0018     explicit UnitTestClient_P(edm::ParameterSet const& p) : useLogFlush(true), queueFillers(1) {
0019       useLogFlush = p.getUntrackedParameter<bool>("useLogFlush", useLogFlush);
0020       queueFillers = p.getUntrackedParameter<int>("queueFillers", queueFillers);
0021     }
0022 
0023     void analyze(edm::StreamID, edm::Event const&, edm::EventSetup const&) const override;
0024 
0025   private:
0026     bool useLogFlush;
0027     int queueFillers;
0028   };
0029 
0030   void UnitTestClient_P::analyze(edm::StreamID, edm::Event const&, edm::EventSetup const&) const {
0031     edm::LogWarning("configuration") << "useLogFlush = " << useLogFlush << " queueFillers = " << queueFillers;
0032     std::string longMessage;
0033     for (int k = 0; k < 100; k++) {
0034       longMessage += "Line in long message\n";
0035     }
0036     for (int i = 0; i < queueFillers; ++i) {
0037       edm::LogInfo("cat") << "message " << i << "\n" << longMessage;
0038     }
0039 
0040     edm::LogError("keyMessage") << "This message is issued just before abort";
0041     if (useLogFlush)
0042       edm::FlushMessageLog();
0043     _exit(0);
0044   }
0045 
0046 }  // namespace edmtest
0047 
0048 using edmtest::UnitTestClient_P;
0049 DEFINE_FWK_MODULE(UnitTestClient_P);