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
// UnitTestClient_A_suppTest is a variant on UnitTestClient_A
// that adds a function call (foo()) to the end of the statemnts
// of a LogDebug and a LogInfo.  foo() has a side efffect
// (a write to cerr).  What we are testing is whether when LogDebug
// is suppressed because EDM_ML_DEBUG is not defined, foo() is not
// called.
//
// The correct behavior is that cerr will get two lines of
// foo(LogInfo) was called.
// But cerr should get no lines of
// foo(LogDebug) was called.
//
// Test passed 9/27/10

#include "FWCore/MessageService/test/UnitTestClient_A.h"
#include "FWCore/MessageLogger/interface/MessageLogger.h"
#include "FWCore/Framework/interface/MakerMacros.h"

#include <iostream>
#include <string>

// TEMPORARY - to test suppression
static std::string foo(std::string const& x) {
  std::cerr << "foo(" << x << ") was called.\n";
  return std::string();
}

namespace edmtest {

  void UnitTestClient_A::analyze(edm::Event const& /*unused*/
                                 ,
                                 edm::EventSetup const& /*unused*/
  ) {
    std::string empty_;
    std::string file_ = "nameOfFile";
    LogDebug("cat_A") << "LogDebug was used to send this message"
                      // TEMPORARY change to test suppression
                      << foo("LogDebug");
    LogDebug("cat_B") << "LogDebug was used to send this other message";
    edm::LogError("cat_A") << "LogError was used to send this message"
                           << "-which is long enough to span lines but-"
                           << "will not be broken up by the logger any more";
    edm::LogError("cat_B") << "LogError was used to send this other message";
    edm::LogWarning("cat_A") << "LogWarning was used to send this message";
    edm::LogWarning("cat_B") << "LogWarning was used to send this other message";
    edm::LogInfo("cat_A") << "LogInfo was used to send this message"
                          // TEMPORARY change to test suppression
                          << foo("LogInfo");
    edm::LogInfo("cat_B") << "LogInfo was used to send this other message";
    edm::LogInfo("FwkTest") << "<Message>LogInfo was used to send a job report</Message>";

  }  // MessageLoggerClient::analyze()

}  // namespace edmtest

using edmtest::UnitTestClient_A;
DEFINE_FWK_MODULE(UnitTestClient_A);