00001 #include "FWCore/MessageLogger/interface/MessageLogger.h" 00002 #include "FWCore/MessageLogger/interface/MessageLoggerQ.h" 00003 00004 // Change Log 00005 // 00006 // 12/12/07 mf elimination of dummyLogDebugObject_, dummyLogTraceObject_ 00007 // (see change log 8 in MessageLogger.h) 00008 // 00009 // 12/14/07 mf Moved the static free function onlyLowestDirectory 00010 // to a class member function of LogDebug_, changing 00011 // name to a more descriptive stripLeadingDirectoryTree. 00012 // Cures the 2600-copies-of-this-function complaint. 00013 // Implementation of this is moved into this .cc file. 00014 // 00015 // 6/20/08 mf Have flushMessageLog() check messageLoggerScribeIsRunning 00016 // (in the message drop) to avoid hangs if that thread is not 00017 // around. 00018 // 00019 // 11/18/08 wmtan Use explicit non-inlined destructors 00020 // 00021 // 8/11/09 mf setStandAloneMessageThreshold() and 00022 // squelchStandAloneMessageCategory() 00023 // 00024 // 10/29/09 wmtan Use explicit non-inlined constructors for LogDebug_ 00025 // and LogTrace_ 00026 // 00027 // 8/11/09 mf setStandAloneMessageThreshold() and 00028 // squelchStandAloneMessageCategory() 00029 // 00030 // 9/23/10 mf Initialize debugEnabled according to 00031 // MessageDrop::debugAlwaysSuppressed, rather than 00032 // just true. See change 21 of MessageLogger.h. 00033 // 00034 // 9/27/10 mf isDebugEnabled() - check that debugAlwaysSuppressed is 00035 // false before examining debugEnabled, which in principle 00036 // ought to be thread-specific thus more expensive to look at. 00037 // 00038 // 9/27/10b mf dtor for LogWarningThatSuppressesLikeLogInfo - see 00039 // change log 22 in MessageLogger.h 00040 // 00041 // 11/30/10 mf SnapshotMessageLog() method to force MessageDrop to capture any 00042 // pointed-to strings in anticipation of key objects going 00043 // away before a message is going to be issued. 00044 // 00045 // 00046 // 7/6/11 fwyzard Add support for discarding LogError-level messages 00047 // on a per-module basis (needed at HLT) 00048 // ------------------------------------------------------------------------ 00049 00050 namespace edm { 00051 00052 LogInfo::~LogInfo() {} 00053 LogWarning::~LogWarning() {} 00054 LogError::~LogError() {} 00055 LogAbsolute::~LogAbsolute() {} 00056 LogSystem::~LogSystem() {} 00057 LogVerbatim::~LogVerbatim() {} 00058 LogDebug_::~LogDebug_() {} 00059 LogTrace_::~LogTrace_() {} 00060 LogPrint::~LogPrint() {} 00061 LogProblem::~LogProblem() {} 00062 LogImportant::~LogImportant() {} 00063 namespace edmmltest { // 9/27/10b mf 00064 LogWarningThatSuppressesLikeLogInfo::~LogWarningThatSuppressesLikeLogInfo() {} 00065 } 00066 00067 void LogStatistics() { 00068 edm::MessageLoggerQ::MLqSUM ( ); // trigger summary info 00069 } 00070 00071 bool isDebugEnabled() { 00072 return ((!edm::MessageDrop::debugAlwaysSuppressed) // 9/27/10 mf 00073 && edm::MessageDrop::debugEnabled ); 00074 } 00075 00076 bool isInfoEnabled() { 00077 return ((!edm::MessageDrop::infoAlwaysSuppressed) // 9/27/10 mf 00078 && edm::MessageDrop::infoEnabled ); 00079 } 00080 00081 bool isWarningEnabled() { 00082 return ((!edm::MessageDrop::warningAlwaysSuppressed) // 9/27/10 mf 00083 && edm::MessageDrop::warningEnabled ); 00084 } 00085 00086 bool isErrorEnabled() { 00087 return edm::MessageDrop::errorEnabled; // 7/6/11 fwyzard 00088 } 00089 00090 void HaltMessageLogging() { 00091 edm::MessageLoggerQ::MLqSHT ( ); // Shut the logger up 00092 } 00093 00094 void FlushMessageLog() { 00095 if (MessageDrop::instance()->messageLoggerScribeIsRunning != 00096 MLSCRIBE_RUNNING_INDICATOR) return; // 6/20/08 mf 00097 edm::MessageLoggerQ::MLqFLS ( ); // Flush the message log queue 00098 } 00099 00100 void snapshotMessageLog() { // 11/30/10 mf 00101 // Capture module name and label strings. 00102 // Use if module objects are about to disappear due to exception, 00103 // but a message will then be issued. 00104 MessageDrop::instance()->snapshot(); 00105 } 00106 00107 bool isMessageProcessingSetUp() { // 6/20/08 mf 00108 // std::cerr << "isMessageProcessingSetUp: \n"; 00109 // std::cerr << "messageLoggerScribeIsRunning = " 00110 // << (int)MessageDrop::instance()->messageLoggerScribeIsRunning << "\n"; 00111 return (MessageDrop::instance()->messageLoggerScribeIsRunning == 00112 MLSCRIBE_RUNNING_INDICATOR); 00113 } 00114 00115 void GroupLogStatistics(std::string const & category) { 00116 std::string * cat_p = new std::string(category); 00117 edm::MessageLoggerQ::MLqGRP (cat_p); // Indicate a group summary category 00118 // Note that the scribe will be responsible for deleting cat_p 00119 } 00120 00121 edm::LogDebug_::LogDebug_( std::string const & id, std::string const & file, int line ) 00122 : ap( ELsuccess,id) 00123 { 00124 *this 00125 << " " 00126 << stripLeadingDirectoryTree(file) 00127 << ":" << line << "\n"; 00128 } 00129 00130 std::string 00131 edm::LogDebug_::stripLeadingDirectoryTree(const std::string & file) const { 00132 std::string::size_type lastSlash = file.find_last_of('/'); 00133 if (lastSlash == std::string::npos) return file; 00134 if (lastSlash == file.size()-1) return file; 00135 return file.substr(lastSlash+1, file.size()-lastSlash-1); 00136 } 00137 00138 edm::LogTrace_::LogTrace_( std::string const & id ) 00139 : ap( ELsuccess,id,true) 00140 { } 00141 00142 void setStandAloneMessageThreshold(std::string const & severity) { 00143 edm::MessageLoggerQ::standAloneThreshold(severity); 00144 } 00145 void squelchStandAloneMessageCategory(std::string const & category){ 00146 edm::MessageLoggerQ::squelch(category); 00147 } 00148 00149 } // namespace edm