Back to home page

Project CMSSW displayed by LXR

 
 

    


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

0001 // UnitTestClient_A_suppTest is a variant on UnitTestClient_A
0002 // that adds a function call (foo()) to the end of the statemnts
0003 // of a LogDebug and a LogInfo.  foo() has a side efffect
0004 // (a write to cerr).  What we are testing is whether when LogDebug
0005 // is suppressed because EDM_ML_DEBUG is not defined, foo() is not
0006 // called.
0007 //
0008 // The correct behavior is that cerr will get two lines of
0009 // foo(LogInfo) was called.
0010 // But cerr should get no lines of
0011 // foo(LogDebug) was called.
0012 //
0013 // Test passed 9/27/10
0014 
0015 #include "FWCore/MessageService/test/UnitTestClient_A.h"
0016 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0017 #include "FWCore/Framework/interface/MakerMacros.h"
0018 
0019 #include <iostream>
0020 #include <string>
0021 
0022 // TEMPORARY - to test suppression
0023 static std::string foo(std::string const& x) {
0024   std::cerr << "foo(" << x << ") was called.\n";
0025   return std::string();
0026 }
0027 
0028 namespace edmtest {
0029 
0030   void UnitTestClient_A::analyze(edm::Event const& /*unused*/
0031                                  ,
0032                                  edm::EventSetup const& /*unused*/
0033   ) {
0034     std::string empty_;
0035     std::string file_ = "nameOfFile";
0036     LogDebug("cat_A") << "LogDebug was used to send this message"
0037                       // TEMPORARY change to test suppression
0038                       << foo("LogDebug");
0039     LogDebug("cat_B") << "LogDebug was used to send this other message";
0040     edm::LogError("cat_A") << "LogError was used to send this message"
0041                            << "-which is long enough to span lines but-"
0042                            << "will not be broken up by the logger any more";
0043     edm::LogError("cat_B") << "LogError was used to send this other message";
0044     edm::LogWarning("cat_A") << "LogWarning was used to send this message";
0045     edm::LogWarning("cat_B") << "LogWarning was used to send this other message";
0046     edm::LogInfo("cat_A") << "LogInfo was used to send this message"
0047                           // TEMPORARY change to test suppression
0048                           << foo("LogInfo");
0049     edm::LogInfo("cat_B") << "LogInfo was used to send this other message";
0050     edm::LogInfo("FwkTest") << "<Message>LogInfo was used to send a job report</Message>";
0051 
0052   }  // MessageLoggerClient::analyze()
0053 
0054 }  // namespace edmtest
0055 
0056 using edmtest::UnitTestClient_A;
0057 DEFINE_FWK_MODULE(UnitTestClient_A);