Back to home page

Project CMSSW displayed by LXR

 
 

    


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

0001 // ----------------------------------------------------------------------
0002 //
0003 // ELdestination.cc
0004 //
0005 // History:
0006 //
0007 // 7/5/98       mf      Created
0008 // 6/16/99      jvr     Allow suppress/include options on destinations
0009 // 7/2/99       jvr     Added separate/attachTime, Epilogue, and Serial
0010 //                      options
0011 // 6/7/00       web     Consolidate ELdestination/X; add filterModule()
0012 // 8/22/00      web     Fix omitted .getSymbol() call
0013 // 10/4/00      mf      excludeModule()
0014 // 1/15/01      mf      setLineLength()
0015 // 2/13/01      mf      fix written by pc to accomodate NT problem with
0016 //                      static init { $001$ }.  Corresponding fix is in
0017 //                      .h file.
0018 // 3/13/01      mf      statisticsMap()
0019 // 4/05/01      mf      multi-module filtering
0020 // 4/12/01      mf      repair multi-module filtering
0021 // 6/23/03      mf      changeFile(), flush()
0022 // 1/10/06      mf      finish()
0023 // 6/19/08  mf      summaryForJobReport()
0024 //
0025 // ----------------------------------------------------------------------
0026 
0027 #include <iostream>
0028 #include <fstream>
0029 
0030 #include "FWCore/MessageService/src/ELdestination.h"
0031 
0032 // Possible Traces:
0033 // #define ELdestinationCONSTRUCTOR_TRACE
0034 using namespace edm::messagelogger;
0035 
0036 namespace edm {
0037   namespace service {
0038     // Fix $001 2/13/01 mf
0039 #ifdef DEFECT_NO_STATIC_CONST_INIT
0040     const int ELdestination::defaultLineLength = 80;
0041 #endif
0042 
0043     ELdestination::ELdestination()
0044         : threshold(ELzeroSeverity),
0045           traceThreshold(ELhighestSeverity),
0046           limits(),
0047           preamble("%MSG"),
0048           newline("\n"),
0049           indent("      "),
0050           lineLength(defaultLineLength),
0051           respondToMostModules(false),
0052           ignoreMostModules(false),
0053           respondToThese(),
0054           ignoreThese() {
0055 #ifdef ELdestinationCONSTRUCTOR_TRACE
0056       std::cerr << "Constructor for ELdestination\n";
0057 #endif
0058 
0059     }  // ELdestination()
0060 
0061     ELdestination::~ELdestination() {
0062 #ifdef ELdestinationCONSTRUCTOR_TRACE
0063       std::cerr << "Destructor for ELdestination\n";
0064 #endif
0065 
0066     }  // ~ELdestination()
0067 
0068     // ----------------------------------------------------------------------
0069     // Methods invoked by the ELadministrator:
0070     // ----------------------------------------------------------------------
0071 
0072     bool ELdestination::log(const edm::ErrorObj&) { return false; }
0073 
0074     // ----------------------------------------------------------------------
0075     // Methods invoked through the ELdestControl handle:
0076     // ----------------------------------------------------------------------
0077 
0078     // Each of these must be overridden by any destination for which they make
0079     // sense.   In this base class, where they are all no-ops, the methods which
0080     // generate data to a destination, stream or stream will warn at that place,
0081     // and all the no-op methods will issue an ELwarning2 at their own destination.
0082 
0083     static const std::string hereMsg = "available via this destination";
0084     static const std::string noosMsg = "No ostream";
0085     static const std::string notELoutputMsg = "This destination is not an ELoutput";
0086 
0087     // ----------------------------------------------------------------------
0088     // Behavior control methods invoked by the framework
0089     // ----------------------------------------------------------------------
0090 
0091     void ELdestination::setThreshold(const ELseverityLevel& sv) { threshold = sv; }
0092 
0093     void ELdestination::setTraceThreshold(const ELseverityLevel& sv) { traceThreshold = sv; }
0094 
0095     void ELdestination::setLimit(const std::string& s, int n) { limits.setLimit(s, n); }
0096 
0097     void ELdestination::setInterval(const ELseverityLevel& sv, int interval) { limits.setInterval(sv, interval); }
0098 
0099     void ELdestination::setInterval(const std::string& s, int interval) { limits.setInterval(s, interval); }
0100 
0101     void ELdestination::setLimit(const ELseverityLevel& sv, int n) { limits.setLimit(sv, n); }
0102 
0103     void ELdestination::setTimespan(const std::string& s, int n) { limits.setTimespan(s, n); }
0104 
0105     void ELdestination::setTimespan(const ELseverityLevel& sv, int n) { limits.setTimespan(sv, n); }
0106 
0107     void ELdestination::wipe() { limits.wipe(); }
0108 
0109     void ELdestination::zero() { limits.zero(); }
0110 
0111     void ELdestination::respondToModule(std::string const& moduleName) {
0112       if (moduleName == "*") {
0113         ignoreMostModules = false;
0114         respondToMostModules = true;
0115         ignoreThese.clear();
0116         respondToThese.clear();
0117       } else {
0118         respondToThese.insert(moduleName);
0119         ignoreThese.erase(moduleName);
0120       }
0121     }
0122 
0123     void ELdestination::ignoreModule(std::string const& moduleName) {
0124       if (moduleName == "*") {
0125         respondToMostModules = false;
0126         ignoreMostModules = true;
0127         respondToThese.clear();
0128         ignoreThese.clear();
0129       } else {
0130         ignoreThese.insert(moduleName);
0131         respondToThese.erase(moduleName);
0132       }
0133     }
0134 
0135     void ELdestination::filterModule(std::string const& moduleName) {
0136       ignoreModule("*");
0137       respondToModule(moduleName);
0138     }
0139 
0140     void ELdestination::excludeModule(std::string const& moduleName) {
0141       respondToModule("*");
0142       ignoreModule(moduleName);
0143     }
0144 
0145     void ELdestination::finish() {}
0146 
0147     void ELdestination::setTableLimit(int n) { limits.setTableLimit(n); }
0148 
0149     void ELdestination::changeFile(std::ostream& /*unused*/) {
0150       edm::ErrorObj msg(ELwarning, noosMsg);
0151       msg << notELoutputMsg;
0152       log(msg);
0153     }
0154 
0155     void ELdestination::changeFile(const std::string& filename) {
0156       edm::ErrorObj msg(ELwarning, noosMsg);
0157       msg << notELoutputMsg << newline << "file requested is" << filename;
0158       log(msg);
0159     }
0160 
0161     void ELdestination::flush() {
0162       edm::ErrorObj msg(ELwarning, noosMsg);
0163       msg << "cannot flush()";
0164       log(msg);
0165     }
0166 
0167     // ----------------------------------------------------------------------
0168     // Output format options:
0169     // ----------------------------------------------------------------------
0170 
0171     void ELdestination::suppressText() { ; }  // $$ jvr
0172     void ELdestination::includeText() { ; }
0173 
0174     void ELdestination::suppressModule() { ; }
0175     void ELdestination::includeModule() { ; }
0176 
0177     void ELdestination::suppressSubroutine() { ; }
0178     void ELdestination::includeSubroutine() { ; }
0179 
0180     void ELdestination::suppressTime() { ; }
0181     void ELdestination::includeTime() { ; }
0182 
0183     void ELdestination::suppressContext() { ; }
0184     void ELdestination::includeContext() { ; }
0185 
0186     void ELdestination::suppressSerial() { ; }
0187     void ELdestination::includeSerial() { ; }
0188 
0189     void ELdestination::useFullContext() { ; }
0190     void ELdestination::useContext() { ; }
0191 
0192     void ELdestination::separateTime() { ; }
0193     void ELdestination::attachTime() { ; }
0194 
0195     void ELdestination::separateEpilogue() { ; }
0196     void ELdestination::attachEpilogue() { ; }
0197 
0198     std::string ELdestination::getNewline() const { return newline; }
0199 
0200     int ELdestination::setLineLength(int len) {
0201       int temp = lineLength;
0202       lineLength = len;
0203       return temp;
0204     }
0205 
0206     int ELdestination::getLineLength() const { return lineLength; }
0207 
0208     // ----------------------------------------------------------------------
0209     // Protected helper methods:
0210     // ----------------------------------------------------------------------
0211 
0212     bool ELdestination::thisShouldBeIgnored(std::string const& s) const {
0213       if (respondToMostModules) {
0214         return (ignoreThese.find(s) != ignoreThese.end());
0215       } else if (ignoreMostModules) {
0216         return (respondToThese.find(s) == respondToThese.end());
0217       } else {
0218         return false;
0219       }
0220     }
0221 
0222     void close_and_delete::operator()(std::ostream* os) const {
0223       std::ofstream* p = static_cast<std::ofstream*>(os);
0224       p->close();
0225       delete os;
0226     }
0227 
0228   }  // end of namespace service
0229 }  // end of namespace edm