CMS 3D CMS Logo

ThreadSafeErrorLog.h

Go to the documentation of this file.
00001 #ifndef THREADSAFEERRORLOG_H
00002 #define FWCore_MessageService_ThreadSafeErrorLog_h
00003 
00004 // ----------------------------------------------------------------------
00005 //
00006 // ThreadSafeErrorLog   provides interface to the module-wide variable by which
00007 //                      users issue log messages, but utilizes a user-supplied
00008 //                      mutex class to do the work in a thread-safe fashion.
00009 //
00010 // 5/29/01 mf   Created file.
00011 //
00012 //      Each thread (or each entitiy that could in principle be building up 
00013 //      an error message) should have its own ThreadSafeErrorLog so that
00014 //      composition of multiple messages simultaneously will not lead to 
00015 //      jumbled log output.
00016 //
00017 // ----------------------------------------------------------------------
00018 
00019 
00020 
00021 #include "FWCore/MessageService/interface/ELtsErrorLog.h"
00022 
00023 namespace edm {       
00024 namespace service {       
00025 
00026 
00027 // ----------------------------------------------------------------------
00028 // Prerequisite classes:
00029 // ----------------------------------------------------------------------
00030 
00031 class ELadministrator;
00032 class ELdestControl;
00033 
00034 
00035 // ----------------------------------------------------------------------
00036 // ThreadSafeErrorLog:
00037 // ----------------------------------------------------------------------
00038 
00039 template <class Mutex>
00040 class ThreadSafeErrorLog  : public ELtsErrorLog {
00041 
00042   // Mutex represents the user-defined locking mechanism, which must
00043   // work as follows:  Any instance of a Mutex will when constructed
00044   // obtain the right-to-log-an-error semaphore, and will relinquish 
00045   // that right when it is destructed.
00046 
00047 public:
00048 
00049 // ----------------------------------------------------------------------
00050 // -----  Methods for physicists logging errors:
00051 // ----------------------------------------------------------------------
00052 
00053   // -----  start a new logging operation:
00054   //
00055   inline ThreadSafeErrorLog & operator()
00056                 ( const ELseverityLevel & sev, const ELstring & id );
00057 
00058   inline ErrorLog & operator()( int debugLevel );
00059 
00060   // -----  mutator:
00061   //
00062   using ELtsErrorLog::setSubroutine;
00063 
00064   // -----  logging operations:
00065   //
00066 
00067   inline ThreadSafeErrorLog & emit (const ELstring & s); 
00068                                         // accumulate one part of a message
00069 
00070   inline ThreadSafeErrorLog & operator()( ErrorObj & msg ); 
00071                                         // an entire message
00072 
00073   inline ThreadSafeErrorLog & completeMsg();  // no more parts forthcoming
00074 
00075 // ----------------------------------------------------------------------
00076 // -----  Methods meant for the Module base class in the framework:
00077 // ----------------------------------------------------------------------
00078 
00079   // -----  birth/death:
00080   //
00081   inline ThreadSafeErrorLog();
00082   inline ThreadSafeErrorLog( const ELstring & pkgName );
00083   inline ThreadSafeErrorLog( const ErrorLog & ee );
00084   inline ThreadSafeErrorLog( const ThreadSafeErrorLog<Mutex> & ee );
00085   inline virtual ~ThreadSafeErrorLog();
00086 
00087   // -----  mutators:
00088   //
00089   using ELtsErrorLog::setModule;                // These two are 
00090   using ELtsErrorLog::setPackage;               //   IDENTICAL
00091 
00092   using ELtsErrorLog::setProcess;               
00093         // Unlike ErrorLog, ThreadSafeErrorLog can have a process name
00094         // distinct from that found in the ELadministrator
00095 
00096   // -----  logging collected message:
00097   //
00098   inline ThreadSafeErrorLog & operator()( int nbytes, char * data );
00099 
00100   // -----  advanced control options:
00101 
00102   using ELtsErrorLog::setHexTrigger;            
00103   using ELtsErrorLog::setDiscardThreshold;              
00104   using ELtsErrorLog::getELdestControl;         
00105   using ELtsErrorLog::setDebugVerbosity;
00106   using ELtsErrorLog::setDebugMessages;
00107                 
00108   // -----  No member data; it is all held by ELtsErrorLog
00109 
00110 };  // ThreadSafeErrorLog
00111 
00112 // ----------------------------------------------------------------------
00113 // Global functions:
00114 // ----------------------------------------------------------------------
00115 
00116 template <class Mutex>
00117 inline ThreadSafeErrorLog<Mutex> & operator<<
00118         ( ThreadSafeErrorLog<Mutex> & e, void (* f)(ErrorLog &) );
00119                                 // allow log << endmsg
00120                                 // SAME arg. signature as for ErrorLog
00121 
00122 template <class Mutex, class T>
00123 inline ThreadSafeErrorLog<Mutex> &
00124         operator<<( ThreadSafeErrorLog<Mutex> & e, const T & t );
00125 
00126 // ----------------------------------------------------------------------
00127 
00128 
00129 }        // end of namespace service
00130 }       // end of namespace edm
00131 
00132 
00133 // ----------------------------------------------------------------------
00134 // .icc
00135 // ----------------------------------------------------------------------
00136 
00137 #define THREADSAFEERRORLOG_ICC
00138   #include "FWCore/MessageLogger/interface/ThreadSafeErrorLog.icc"
00139 #undef  THREADSAFEERRORLOG_ICC
00140 
00141 
00142 // ----------------------------------------------------------------------
00143 
00144 
00145 #endif  // THREADSAFEERRORLOG_H

Generated on Tue Jun 9 17:36:18 2009 for CMSSW by  doxygen 1.5.4