CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_4_1_8_patch13/src/FWCore/MessageService/src/ELdestination.cc

Go to the documentation of this file.
00001 // ----------------------------------------------------------------------
00002 //
00003 // ELdestination.cc
00004 //
00005 // History:
00006 //
00007 // 7/5/98       mf      Created
00008 // 6/16/99      jvr     Allow suppress/include options on destinations
00009 // 7/2/99       jvr     Added separate/attachTime, Epilogue, and Serial
00010 //                      options
00011 // 6/7/00       web     Consolidate ELdestination/X; add filterModule()
00012 // 8/22/00      web     Fix omitted .getSymbol() call
00013 // 10/4/00      mf      excludeModule()
00014 // 1/15/01      mf      setLineLength()
00015 // 2/13/01      mf      fix written by pc to accomodate NT problem with
00016 //                      static init { $001$ }.  Corresponding fix is in
00017 //                      .h file.
00018 // 3/13/01      mf      statisticsMap()
00019 // 4/05/01      mf      multi-module filtering
00020 // 4/12/01      mf      repair multi-module filtering
00021 // 6/23/03      mf      changeFile(), flush()
00022 // 1/10/06      mf      finish()
00023 // 6/19/08      mf      summaryForJobReport()
00024 //
00025 // ----------------------------------------------------------------------
00026 
00027 
00028 #include <iostream>
00029 #include <fstream>
00030 
00031 #include "FWCore/MessageService/interface/ELdestination.h"
00032 #include "FWCore/MessageService/interface/ELdestControl.h"
00033 
00034 // Possible Traces:
00035 // #define ELdestinationCONSTRUCTOR_TRACE
00036 
00037 namespace edm {
00038 namespace service {
00039                                          // Fix $001 2/13/01 mf
00040 #ifdef DEFECT_NO_STATIC_CONST_INIT
00041   const int ELdestination::defaultLineLength = 80;
00042 #endif
00043 
00044 ELdestination::ELdestination()
00045 : threshold     ( ELzeroSeverity    )
00046 , traceThreshold( ELhighestSeverity )
00047 , limits        (                   )
00048 , preamble      ( "%MSG"            )
00049 , newline       ( "\n"              )
00050 , indent        ( "      "          )
00051 , lineLength    ( defaultLineLength )
00052 , ignoreMostModules (false)
00053 , respondToThese()
00054 , respondToMostModules (false)
00055 , ignoreThese()
00056 {
00057 
00058   #ifdef ELdestinationCONSTRUCTOR_TRACE
00059     std::cerr << "Constructor for ELdestination\n";
00060   #endif
00061 
00062 }  // ELdestination()
00063 
00064 
00065 ELdestination::~ELdestination()  {
00066 
00067   #ifdef ELdestinationCONSTRUCTOR_TRACE
00068     std::cerr << "Destructor for ELdestination\n";
00069   #endif
00070 
00071 }  // ~ELdestination()
00072 
00073 
00074 // ----------------------------------------------------------------------
00075 // Methods invoked by the ELadministrator:
00076 // ----------------------------------------------------------------------
00077 
00078 bool ELdestination::log( const edm::ErrorObj & msg )  { return false; }
00079 
00080 
00081 // ----------------------------------------------------------------------
00082 // Methods invoked through the ELdestControl handle:
00083 // ----------------------------------------------------------------------
00084 
00085 // Each of these must be overridden by any destination for which they make
00086 // sense.   In this base class, where they are all no-ops, the methods which
00087 // generate data to a destination, stream or stream will warn at that place,
00088 // and all the no-op methods will issue an ELwarning2 at their own destination.
00089 
00090 
00091 static ELstring noSummarizationMsg = "No summarization()";
00092 static ELstring noSummaryMsg = "No summary()";
00093 static ELstring noClearSummaryMsg = "No clearSummary()";
00094 static ELstring hereMsg = "available via this destination";
00095 static ELstring noosMsg = "No ostream";
00096 static ELstring notELoutputMsg = "This destination is not an ELoutput";
00097 
00098 void ELdestination::clearSummary()  {
00099 
00100   edm::ErrorObj msg( ELwarning2, noClearSummaryMsg );
00101   msg << hereMsg;
00102   log( msg );
00103 
00104 }  // clearSummary()
00105 
00106 
00107 void ELdestination::wipe()  { limits.wipe(); }
00108 
00109 
00110 void ELdestination::zero()  { limits.zero(); }
00111 
00112 void ELdestination::respondToModule( ELstring const & moduleName )  {
00113   if (moduleName=="*") {
00114     ignoreMostModules = false;
00115     respondToMostModules = true;
00116     ignoreThese.clear();
00117     respondToThese.clear();
00118   } else {
00119     respondToThese.insert(moduleName);
00120     ignoreThese.erase(moduleName);
00121   }
00122 }
00123 
00124 void ELdestination::ignoreModule( ELstring const & moduleName )  {
00125   if (moduleName=="*") {
00126     respondToMostModules = false;
00127     ignoreMostModules = true;
00128     respondToThese.clear();
00129     ignoreThese.clear();
00130   } else {
00131     ignoreThese.insert(moduleName);
00132     respondToThese.erase(moduleName);
00133   }
00134 }
00135 
00136 void ELdestination::filterModule( ELstring const & moduleName )  {
00137   ignoreModule("*");
00138   respondToModule(moduleName);
00139 }
00140 
00141 void ELdestination::excludeModule( ELstring const & moduleName )  {
00142   respondToModule("*");
00143   ignoreModule(moduleName);
00144 }
00145 
00146 void ELdestination::summary( )  { }
00147 
00148 void ELdestination::summary( ELdestControl & dest, const ELstring & title )  {
00149 
00150   edm::ErrorObj msg( ELwarning2, noSummaryMsg );
00151   msg << noSummaryMsg << " " << hereMsg << dest.getNewline() << title;
00152   dest.log( msg );
00153 
00154 }  // summary()
00155 
00156 
00157 void ELdestination::summary( std::ostream & os, const ELstring & title )  {
00158 
00159   os << "%MSG" << ELwarning2.getSymbol() << " "
00160        << noSummaryMsg << " " << hereMsg << std::endl
00161      << title << std::endl;
00162 
00163 }  // summary()
00164 
00165 
00166 void ELdestination::summary( ELstring & s, const ELstring & title )  {
00167 
00168   s = ELstring("%MSG") + ELwarning2.getSymbol() + " "
00169       + noSummaryMsg + " " + hereMsg + "\n"
00170     + title + "\n";
00171 
00172 }  // summary()
00173 
00174 void ELdestination::summaryForJobReport(std::map<std::string, double> & sm) { }
00175 
00176 void ELdestination::finish() {  }
00177 
00178 void ELdestination::setTableLimit( int n )  { limits.setTableLimit( n ); }
00179 
00180 
00181 void ELdestination::summarization(
00182   const ELstring & title
00183 , const ELstring & sumLines )  {
00184 
00185   edm::ErrorObj  msg( ELwarning2, noSummarizationMsg );
00186   msg << hereMsg << newline << title;
00187   log( msg );
00188 
00189 }
00190 
00191 std::map<ELextendedID , StatsCount> ELdestination::statisticsMap() const {
00192   return std::map<ELextendedID , StatsCount> ();
00193 }
00194 
00195 void ELdestination::changeFile (std::ostream & os) {
00196   edm::ErrorObj  msg( ELwarning2, noosMsg );
00197   msg << notELoutputMsg;
00198   log( msg );
00199 }
00200 
00201 void ELdestination::changeFile (const ELstring & filename) {
00202   edm::ErrorObj  msg( ELwarning2, noosMsg );
00203   msg << notELoutputMsg << newline << "file requested is" << filename;
00204   log( msg );
00205 }
00206 
00207 void ELdestination::flush () {
00208   edm::ErrorObj  msg( ELwarning2, noosMsg );
00209   msg << "cannot flush()";
00210   log( msg );
00211 }
00212 
00213 // ----------------------------------------------------------------------
00214 // Output format options:
00215 // ----------------------------------------------------------------------
00216 
00217 void ELdestination::suppressText()  { ; }                      // $$ jvr
00218 void ELdestination::includeText()   { ; }
00219 
00220 void ELdestination::suppressModule()  { ; }
00221 void ELdestination::includeModule()   { ; }
00222 
00223 void ELdestination::suppressSubroutine()  { ; }
00224 void ELdestination::includeSubroutine()   { ; }
00225 
00226 void ELdestination::suppressTime()  { ; }
00227 void ELdestination::includeTime()   { ; }
00228 
00229 void ELdestination::suppressContext()  { ; }
00230 void ELdestination::includeContext()   { ; }
00231 
00232 void ELdestination::suppressSerial()  { ; }
00233 void ELdestination::includeSerial()   { ; }
00234 
00235 void ELdestination::useFullContext()  { ; }
00236 void ELdestination::useContext()      { ; }
00237 
00238 void ELdestination::separateTime()  { ; }
00239 void ELdestination::attachTime()    { ; }
00240 
00241 void ELdestination::separateEpilogue()  { ; }
00242 void ELdestination::attachEpilogue()    { ; }
00243 
00244 void ELdestination::noTerminationSummary()  { ; }
00245 
00246 ELstring ELdestination::getNewline() const  { return newline; }
00247 
00248 int ELdestination::setLineLength (int len) {
00249   int temp=lineLength;
00250   lineLength = len;
00251   return temp;
00252 }
00253 
00254 int ELdestination::getLineLength () const { return lineLength; }
00255 
00256 
00257 // ----------------------------------------------------------------------
00258 // Protected helper methods:
00259 // ----------------------------------------------------------------------
00260 
00261 bool ELdestination::thisShouldBeIgnored(const ELstring & s) const {
00262   if (respondToMostModules) {
00263     return ( ignoreThese.find(s) != ignoreThese.end() );
00264   } else if (ignoreMostModules) {
00265     return ( respondToThese.find(s) == respondToThese.end() );
00266   } else {
00267   return false;
00268   }
00269 }
00270 
00271 
00272 void close_and_delete::operator()(std::ostream* os) const {
00273   std::ofstream* p = static_cast<std::ofstream*>(os);
00274   p->close();
00275   delete os;
00276 }
00277 
00278 } // end of namespace service  
00279 } // end of namespace edm