#include <MessageLoggerScribe.h>
Public Member Functions | |
MessageLoggerScribe (boost::shared_ptr< ThreadQueue > queue) | |
--- If queue is NULL, this sets singleThread true | |
virtual void | run () |
virtual void | runCommand (MessageLoggerQ::OpCode opcode, void *operand) |
virtual | ~MessageLoggerScribe () |
Static Public Member Functions | |
static ErrorLog * | getErrorLog_ptr () |
Private Types | |
typedef ParameterSet | PSet |
typedef std::string | String |
typedef std::vector< String > | vString |
Private Member Functions | |
void | configure_default_fwkJobReport (ELdestControl &dest_ctrl) |
void | configure_dest (ELdestControl &dest_ctrl, String const &filename) |
void | configure_errorlog () |
void | configure_external_dests () |
void | configure_fwkJobReports () |
void | configure_ordinary_destinations () |
void | configure_statistics () |
template<class T > | |
T | getAparameter (PSet const &p, std::string const &id, T const &def) |
void | log (ErrorObj *errorobj_p) |
void | parseCategories (std::string const &s, std::vector< std::string > &cats) |
void | setStaticErrorLog_ptr () |
void | triggerFJRmessageSummary (std::map< std::string, double > &sm) |
void | triggerStatisticsSummaries () |
Private Attributes | |
bool | active |
ELadministrator * | admin_p |
bool | clean_slate_configuration |
int | count |
bool | done |
ELdestControl | early_dest |
boost::shared_ptr< ErrorLog > | errorlog_p |
std::vector< NamedDestination * > | extern_dests |
std::vector< boost::shared_ptr < std::ofstream > > | file_ps |
boost::shared_ptr< PSet > | job_pset_p |
std::string | jobReportOption |
boost::shared_ptr< ThreadQueue > | m_queue |
value_ptr< MessageLoggerDefaults > | messageLoggerDefaults |
MsgContext | msg_context |
std::vector< String > | ordinary_destination_filenames |
bool | purge_mode |
bool | singleThread |
std::vector< ELdestControl > | statisticsDestControls |
std::vector< bool > | statisticsResets |
std::map< String, std::ostream * > | stream_ps |
Static Private Attributes | |
static ErrorLog * | static_errorlog_p |
Definition at line 86 of file MessageLoggerScribe.h.
typedef ParameterSet edm::service::MessageLoggerScribe::PSet [private] |
Definition at line 111 of file MessageLoggerScribe.h.
typedef std::string edm::service::MessageLoggerScribe::String [private] |
Definition at line 109 of file MessageLoggerScribe.h.
typedef std::vector<String> edm::service::MessageLoggerScribe::vString [private] |
Definition at line 110 of file MessageLoggerScribe.h.
edm::service::MessageLoggerScribe::MessageLoggerScribe | ( | boost::shared_ptr< ThreadQueue > | queue | ) | [explicit] |
--- If queue is NULL, this sets singleThread true
Definition at line 216 of file MessageLoggerScribe.cc.
References admin_p, msg_context, and edm::service::ELadministrator::setContextSupplier().
: admin_p ( ELadministrator::instance() ) , early_dest( admin_p->attach(ELoutput(std::cerr, false)) ) , errorlog_p( new ErrorLog() ) , file_ps ( ) , job_pset_p( ) , extern_dests( ) , jobReportOption( ) , clean_slate_configuration( true ) , active( true ) , singleThread (queue.get() == 0) // changeLog 36 , done (false) // changeLog 32 , purge_mode (false) // changeLog 32 , count (false) // changeLog 32 , m_queue(queue) // changeLog 36 { admin_p->setContextSupplier(msg_context); }
edm::service::MessageLoggerScribe::~MessageLoggerScribe | ( | ) | [virtual] |
Definition at line 235 of file MessageLoggerScribe.cc.
References admin_p, extern_dests, and edm::service::ELadministrator::finish().
{ admin_p->finish(); assert( extern_dests.empty() ); // nothing to do }
void edm::service::MessageLoggerScribe::configure_default_fwkJobReport | ( | ELdestControl & | dest_ctrl | ) | [private] |
Definition at line 767 of file MessageLoggerScribe.cc.
References edm::service::ELdestControl::setLimit(), edm::service::ELdestControl::setLineLength(), and edm::service::ELdestControl::suppressTime().
Referenced by configure_fwkJobReports().
{ dest_ctrl.setLimit("*", 0 ); String msgID = "FwkJob"; int FwkJob_limit = 10000000; dest_ctrl.setLimit(msgID, FwkJob_limit); dest_ctrl.setLineLength(32000); dest_ctrl.suppressTime(); } // MessageLoggerScribe::configure_default_fwkJobReport()
void edm::service::MessageLoggerScribe::configure_dest | ( | ELdestControl & | dest_ctrl, |
String const & | filename | ||
) | [private] |
Definition at line 525 of file MessageLoggerScribe.cc.
References ecalBxOrbitNumberGrapher_cfg::categories, python::rootplot::argparse::category, edm::copy_all(), edm::MessageDrop::debugAlwaysSuppressed, edm::ELseverityLevel::ELsev_info, edm::ELseverityLevel::ELsev_success, edm::ELseverityLevel::ELsev_warning, lut2db_cfg::filename, edm::MessageDrop::infoAlwaysSuppressed, MergeJob_cfg::interval, job_pset_p, MessageLogger_cff::limit, messageLoggerDefaults, dtDQMClient_cfg::noLineBreaks, edm::service::ELdestControl::setInterval(), edm::service::ELdestControl::setLimit(), edm::service::ELdestControl::setLineLength(), edm::service::ELdestControl::setThreshold(), edm::service::ELdestControl::setTimespan(), AlCaHLTBitMon_QueryRunRegistry::string, edm::service::ELdestControl::suppressTime(), and edm::MessageDrop::warningAlwaysSuppressed.
Referenced by configure_external_dests(), configure_fwkJobReports(), configure_ordinary_destinations(), and configure_statistics().
{ static const int NO_VALUE_SET = -45654; // change log 2 vString empty_vString; PSet empty_PSet; String empty_String; // Defaults: // change log 3a const std::string COMMON_DEFAULT_THRESHOLD = "INFO"; const int COMMON_DEFAULT_LIMIT = NO_VALUE_SET; const int COMMON_DEFAULT_INTERVAL = NO_VALUE_SET; // change log 6 const int COMMON_DEFAULT_TIMESPAN = NO_VALUE_SET; char const* severity_array[] = {"WARNING", "INFO", "ERROR", "DEBUG"}; vString const severities(severity_array+0, severity_array+4); // grab list of categories vString categories = getAparameter<vString>(*job_pset_p, "categories", empty_vString); // grab list of messageIDs -- these are a synonym for categories // Note -- the use of messageIDs is deprecated in favor of categories { vString messageIDs = getAparameter<vString>(*job_pset_p, "messageIDs", empty_vString); // combine the lists, not caring about possible duplicates (for now) copy_all( messageIDs, std::back_inserter(categories) ); } // no longer need messageIDs // grab list of hardwired categories (hardcats) -- these are to be added // to the list of categories -- change log 24 { std::vector<std::string> hardcats = messageLoggerDefaults->categories; // combine the lists, not caring about possible duplicates (for now) copy_all( hardcats, std::back_inserter(categories) ); } // no longer need hardcats // grab default threshold common to all destinations String default_threshold = getAparameter<String>(*job_pset_p, "threshold", empty_String); // change log 3a // change log 24 // grab default limit/interval/timespan common to all destinations/categories: PSet default_pset = getAparameter<PSet>(*job_pset_p, "default", empty_PSet); int default_limit = getAparameter<int>(default_pset, "limit", COMMON_DEFAULT_LIMIT); int default_interval = getAparameter<int>(default_pset, "reportEvery", COMMON_DEFAULT_INTERVAL); // change log 6, 10 int default_timespan = getAparameter<int>(default_pset, "timespan", COMMON_DEFAULT_TIMESPAN); // change log 2a // change log 3a String default_pset_threshold = getAparameter<String>(default_pset, "threshold", default_threshold); // change log 34 // grab all of this destination's parameters: PSet dest_pset = getAparameter<PSet>(*job_pset_p, filename, empty_PSet); // See if this is just a placeholder // change log 9 bool is_placeholder = getAparameter<bool>(dest_pset, "placeholder", false); if (is_placeholder) return; // grab this destination's default limit/interval/timespan: PSet dest_default_pset = getAparameter<PSet>(dest_pset, "default", empty_PSet); int dest_default_limit = getAparameter<int>(dest_default_pset, "limit", default_limit); int dest_default_interval = getAparameter<int>(dest_default_pset, "reportEvery", default_interval); // change log 6 int dest_default_timespan = getAparameter<int>(dest_default_pset, "timespan", default_timespan); // change log 1a if ( dest_default_limit != NO_VALUE_SET ) { if ( dest_default_limit < 0 ) dest_default_limit = 2000000000; dest_ctrl.setLimit("*", dest_default_limit ); } // change log 1b, 2a, 2b if ( dest_default_interval != NO_VALUE_SET ) { // change log 6 dest_ctrl.setInterval("*", dest_default_interval ); } if ( dest_default_timespan != NO_VALUE_SET ) { if ( dest_default_timespan < 0 ) dest_default_timespan = 2000000000; dest_ctrl.setTimespan("*", dest_default_timespan ); } // change log 1b, 2a, 2b // establish this destination's threshold: String dest_threshold = getAparameter<String>(dest_pset, "threshold", default_threshold); if (dest_threshold == empty_String) { dest_threshold = default_threshold; } if (dest_threshold == empty_String) { // change log 34 dest_threshold = default_pset_threshold; } if (dest_threshold == empty_String) { dest_threshold = messageLoggerDefaults->threshold(filename); } if (dest_threshold == empty_String) dest_threshold = COMMON_DEFAULT_THRESHOLD; ELseverityLevel threshold_sev(dest_threshold); dest_ctrl.setThreshold(threshold_sev); // change log 37 if (threshold_sev <= ELseverityLevel::ELsev_success) { edm::MessageDrop::debugAlwaysSuppressed = false; } if (threshold_sev <= ELseverityLevel::ELsev_info) { edm::MessageDrop::infoAlwaysSuppressed = false; } if (threshold_sev <= ELseverityLevel::ELsev_warning) { edm::MessageDrop::warningAlwaysSuppressed = false; } // establish this destination's limit/interval/timespan for each category: for( vString::const_iterator id_it = categories.begin() ; id_it != categories.end() ; ++id_it ) { String msgID = *id_it; PSet default_category_pset = getAparameter<PSet>(default_pset, msgID, empty_PSet); // change log 5 PSet category_pset = getAparameter<PSet>(dest_pset, msgID, default_category_pset); int category_default_limit = getAparameter<int>(default_category_pset, "limit", NO_VALUE_SET); int limit = getAparameter<int>(category_pset, "limit", category_default_limit); if (limit == NO_VALUE_SET) limit = dest_default_limit; // change log 7 int category_default_interval = getAparameter<int>(default_category_pset, "reportEvery", NO_VALUE_SET); int interval = getAparameter<int>(category_pset, "reportEvery",category_default_interval); if (interval == NO_VALUE_SET) interval = dest_default_interval; // change log 6 and then 7 int category_default_timespan = getAparameter<int>(default_category_pset, "timespan", NO_VALUE_SET); int timespan = getAparameter<int>(category_pset, "timespan", category_default_timespan); if (timespan == NO_VALUE_SET) timespan = dest_default_timespan; // change log 7 std::string category = msgID; if ( limit == NO_VALUE_SET ) { // change log 24 limit = messageLoggerDefaults->limit(filename,category); } if ( interval == NO_VALUE_SET ) { // change log 24 interval = messageLoggerDefaults->reportEvery(filename,category); } if ( timespan == NO_VALUE_SET ) { // change log 24 timespan = messageLoggerDefaults->timespan(filename,category); } if( limit != NO_VALUE_SET ) { if ( limit < 0 ) limit = 2000000000; dest_ctrl.setLimit(msgID, limit); } // change log 2a, 2b if( interval != NO_VALUE_SET ) { dest_ctrl.setInterval(msgID, interval); } // change log 6 if( timespan != NO_VALUE_SET ) { if ( timespan < 0 ) timespan = 2000000000; dest_ctrl.setTimespan(msgID, timespan); } // change log 2a, 2b } // for // establish this destination's limit for each severity: for( vString::const_iterator sev_it = severities.begin() ; sev_it != severities.end() ; ++sev_it ) { String sevID = *sev_it; ELseverityLevel severity(sevID); PSet default_sev_pset = getAparameter<PSet>(default_pset, sevID, empty_PSet); PSet sev_pset = getAparameter<PSet>(dest_pset, sevID, default_sev_pset); // change log 5 int limit = getAparameter<int>(sev_pset, "limit", NO_VALUE_SET); if ( limit == NO_VALUE_SET ) { // change log 24 limit = messageLoggerDefaults->sev_limit(filename,sevID); } if( limit != NO_VALUE_SET ) { if (limit < 0) limit = 2000000000; // change log 38 dest_ctrl.setLimit(severity, limit ); } int interval = getAparameter<int>(sev_pset, "reportEvery", NO_VALUE_SET); if ( interval == NO_VALUE_SET ) { // change log 24 interval = messageLoggerDefaults->sev_reportEvery(filename,sevID); } if( interval != NO_VALUE_SET ) dest_ctrl.setInterval(severity, interval); // change log 2 int timespan = getAparameter<int>(sev_pset, "timespan", NO_VALUE_SET); if ( timespan == NO_VALUE_SET ) { // change log 24 timespan = messageLoggerDefaults->sev_timespan(filename,sevID); } if( timespan != NO_VALUE_SET ) { if (timespan < 0) timespan = 2000000000; // change log 38 dest_ctrl.setTimespan(severity, timespan ); } } // for // establish this destination's linebreak policy: bool noLineBreaks_default = getAparameter<bool> (default_pset, "noLineBreaks", false); // change log 5 bool noLineBreaks = getAparameter<bool> (dest_pset, "noLineBreaks", noLineBreaks_default); if (noLineBreaks) { dest_ctrl.setLineLength(32000); } else { int lenDef = 80; int lineLen_default = getAparameter<int> (default_pset, "lineLength", lenDef); // change log 5 int lineLen = getAparameter<int> (dest_pset, "lineLength", lineLen_default); if (lineLen != lenDef) { dest_ctrl.setLineLength(lineLen); } } // if indicated, suppress time stamps in this destination's output bool suppressTime_default = getAparameter<bool> (default_pset, "noTimeStamps", false); bool suppressTime = getAparameter<bool> (dest_pset, "noTimeStamps", suppressTime_default); if (suppressTime) { dest_ctrl.suppressTime(); } } // MessageLoggerScribe::configure_dest()
void edm::service::MessageLoggerScribe::configure_errorlog | ( | ) | [private] |
Definition at line 480 of file MessageLoggerScribe.cc.
References clean_slate_configuration, configure_external_dests(), configure_fwkJobReports(), configure_ordinary_destinations(), configure_statistics(), early_dest, job_pset_p, log(), edm::MessageLoggerQ::LOG_A_MESSAGE, m_queue, singleThread, stream_ps, and edm::service::ELdestControl::suppressTime().
Referenced by runCommand().
{ vString empty_vString; String empty_String; PSet empty_PSet; // The following is present to test pre-configuration message handling: String preconfiguration_message = getAparameter<String> (*job_pset_p, "generate_preconfiguration_message", empty_String); if (preconfiguration_message != empty_String) { // To test a preconfiguration message without first going thru the // configuration we are about to do, we issue the message (so it sits // on the queue), then copy the processing that the LOG_A_MESSAGE case // does. We suppress the timestamp to allow for automated unit testing. early_dest.suppressTime(); LogError ("preconfiguration") << preconfiguration_message; if (!singleThread) { MessageLoggerQ::OpCode opcode; void * operand; m_queue->consume(opcode, operand); // grab next work item from Q assert (opcode == MessageLoggerQ::LOG_A_MESSAGE); ErrorObj * errorobj_p = static_cast<ErrorObj *>(operand); log (errorobj_p); delete errorobj_p; // dispose of the message text } } if ( !stream_ps.empty() ) { LogWarning ("multiLogConfig") << "The message logger has been configured multiple times"; clean_slate_configuration = false; // Change Log 22 } configure_fwkJobReports(); // Change Log 16 configure_ordinary_destinations(); // Change Log 16 configure_statistics(); // Change Log 16 configure_external_dests(); } // MessageLoggerScribe::configure_errorlog()
void edm::service::MessageLoggerScribe::configure_external_dests | ( | ) | [private] |
Definition at line 1176 of file MessageLoggerScribe.cc.
References admin_p, edm::service::ELadministrator::attach(), configure_dest(), extern_dests, and job_pset_p.
Referenced by configure_errorlog(), and runCommand().
{ if( ! job_pset_p ) { // extern_dests.clear(); // change log 12, removed by change log 13 return; } for( std::vector<NamedDestination*>::const_iterator it = extern_dests.begin() ; it != extern_dests.end() ; ++it ) { ELdestination * dest_p = (*it)->dest_p().get(); ELdestControl dest_ctrl = admin_p->attach( *dest_p ); // configure the newly-attached destination: configure_dest( dest_ctrl, (*it)->name() ); delete *it; // dispose of our (copy of the) NamedDestination } extern_dests.clear(); } // MessageLoggerScribe::configure_external_dests
void edm::service::MessageLoggerScribe::configure_fwkJobReports | ( | ) | [private] |
Definition at line 781 of file MessageLoggerScribe.cc.
References admin_p, edm::service::ELadministrator::attach(), clean_slate_configuration, edm::errors::Configuration, configure_default_fwkJobReport(), configure_dest(), Exception, file_ps, lut2db_cfg::filename, benchmark_cfg::fwkJobReports, job_pset_p, jobReportOption, messageLoggerDefaults, stream_ps, and AlCaHLTBitMon_QueryRunRegistry::string.
Referenced by configure_errorlog().
{ vString empty_vString; String empty_String; PSet empty_PSet; // decide whether to configure any job reports at all // Changelog 19 bool jobReportExists = false; bool enableJobReports = false; #ifdef DEFINE_THIS_TO_MAKE_REPORTS_THE_DEFAULT enableJobReports = true; #endif if (jobReportOption != empty_String) enableJobReports = true; if (jobReportOption == "~") enableJobReports = false; // --nojobReport if (!enableJobReports) return; if ((jobReportOption != "*") && (jobReportOption != empty_String)) { const std::string::size_type npos = std::string::npos; if ( jobReportOption.find('.') == npos ) { jobReportOption += ".xml"; } } // grab list of fwkJobReports: vString fwkJobReports = getAparameter<vString>(*job_pset_p, "fwkJobReports", empty_vString); // Use the default list of fwkJobReports if and only if the grabbed list is // empty // change log 24 if (fwkJobReports.empty()) { fwkJobReports = messageLoggerDefaults->fwkJobReports; } // establish each fwkJobReports destination: for( vString::const_iterator it = fwkJobReports.begin() ; it != fwkJobReports.end() ; ++it ) { String filename = *it; String psetname = filename; // check that this destination is not just a placeholder // change log 20 PSet fjr_pset = getAparameter<PSet>(*job_pset_p, psetname, empty_PSet); bool is_placeholder = getAparameter<bool>(fjr_pset, "placeholder", false); if (is_placeholder) continue; // Modify the file name if extension or name is explicitly specified // change log 14 String explicit_filename = getAparameter<String>(fjr_pset, "filename", empty_String); if (explicit_filename != empty_String) filename = explicit_filename; String explicit_extension = getAparameter<String>(fjr_pset, "extension", empty_String); if (explicit_extension != empty_String) { if (explicit_extension[0] == '.') { filename += explicit_extension; } else { filename = filename + "." + explicit_extension; } } // Attach a default extension of .xml if there is no extension on a file std::string actual_filename = filename; // change log 4 const std::string::size_type npos = std::string::npos; if ( filename.find('.') == npos ) { actual_filename += ".xml"; } // Check that this is not a duplicate name // change log 18 if ( stream_ps.find(actual_filename)!=stream_ps.end() ) { if (clean_slate_configuration) { // change log 22 throw edm::Exception ( edm::errors::Configuration ) <<"Duplicate name for a MessageLogger Framework Job Report Destination: " << actual_filename << "\n"; } else { LogWarning("duplicateDestination") <<"Duplicate name for a MessageLogger Framework Job Report Destination: " << actual_filename << "\n" << "Only original configuration instructions are used"; continue; } } jobReportExists = true; // Changelog 19 if ( actual_filename == jobReportOption ) jobReportOption = empty_String; boost::shared_ptr<std::ofstream> os_sp(new std::ofstream(actual_filename.c_str())); file_ps.push_back(os_sp); ELdestControl dest_ctrl; dest_ctrl = admin_p->attach( ELfwkJobReport(*os_sp) ); stream_ps[actual_filename] = os_sp.get(); // now configure this destination: configure_dest(dest_ctrl, psetname); } // for [it = fwkJobReports.begin() to end()] // Now possibly add the file specified by --jobReport // Changelog 19 if (jobReportOption==empty_String) return; if (jobReportExists && ( jobReportOption=="*" )) return; if (jobReportOption=="*") jobReportOption = "FrameworkJobReport.xml"; // Check that this report is not already on order -- here the duplicate // name would not be a configuration error, but we shouldn't do it twice std::string actual_filename = jobReportOption; if ( stream_ps.find(actual_filename)!=stream_ps.end() ) return; boost::shared_ptr<std::ofstream> os_sp(new std::ofstream(actual_filename.c_str())); file_ps.push_back(os_sp); ELdestControl dest_ctrl; dest_ctrl = admin_p->attach( ELfwkJobReport(*os_sp) ); stream_ps[actual_filename] = os_sp.get(); // now configure this destination, in the jobreport default manner: configure_default_fwkJobReport (dest_ctrl); }
void edm::service::MessageLoggerScribe::configure_ordinary_destinations | ( | ) | [private] |
Definition at line 902 of file MessageLoggerScribe.cc.
References admin_p, edm::service::ELadministrator::attach(), dtNoiseDBValidation_cfg::cerr, clean_slate_configuration, configure_dest(), gather_cfg::cout, edm::MessageDrop::debugAlwaysSuppressed, gather_cfg::destinations, early_dest, edm::ELhighestSeverity, edm::ELzeroSeverity, file_ps, lut2db_cfg::filename, edm::MessageDrop::infoAlwaysSuppressed, job_pset_p, messageLoggerDefaults, ordinary_destination_filenames, edm::service::ELdestControl::setThreshold(), stream_ps, AlCaHLTBitMon_QueryRunRegistry::string, and edm::MessageDrop::warningAlwaysSuppressed.
Referenced by configure_errorlog().
{ vString empty_vString; String empty_String; PSet empty_PSet; // Initialize unversal suppression variables MessageDrop::debugAlwaysSuppressed=true; // change log 37 MessageDrop::infoAlwaysSuppressed=true; // change log 37 MessageDrop::warningAlwaysSuppressed=true; // change log 37 // grab list of destinations: vString destinations = getAparameter<vString>(*job_pset_p, "destinations", empty_vString); // Use the default list of destinations if and only if the grabbed list is // empty // change log 24 if (destinations.empty()) { destinations = messageLoggerDefaults->destinations; } // dial down the early destination if other dest's are supplied: if( ! destinations.empty() ) early_dest.setThreshold(ELhighestSeverity); // establish each destination: for( vString::const_iterator it = destinations.begin() ; it != destinations.end() ; ++it ) { String filename = *it; String psetname = filename; // check that this destination is not just a placeholder // change log 11 PSet dest_pset = getAparameter<PSet>(*job_pset_p, psetname, empty_PSet); bool is_placeholder = getAparameter<bool>(dest_pset, "placeholder", false); if (is_placeholder) continue; // Modify the file name if extension or name is explicitly specified // change log 14 // Although for an ordinary destination there is no output attribute // for the cfg (you can use filename instead) we provide output() for // uniformity with the statistics destinations. The "right way" to // work this would have been to provide a filename() method, along with // an extension() method. We recognize the potential name confusion here // (filename(filename))! // Determine the destination file name to use if no explicit filename is // supplied in the cfg. String filename_default = getAparameter<String>(dest_pset, "output", empty_String); if ( filename_default == empty_String ) { filename_default = messageLoggerDefaults->output(psetname); // change log 31 if (filename_default == empty_String) { filename_default = filename; } } String explicit_filename = getAparameter<String>(dest_pset, "filename", filename_default); if (explicit_filename != empty_String) filename = explicit_filename; String explicit_extension = getAparameter<String>(dest_pset, "extension", empty_String); if (explicit_extension != empty_String) { if (explicit_extension[0] == '.') { filename += explicit_extension; } else { filename = filename + "." + explicit_extension; } } // Attach a default extension of .log if there is no extension on a file // change log 18 - this had been done in concert with attaching destination std::string actual_filename = filename; // change log 4 if ( (filename != "cout") && (filename != "cerr") ) { const std::string::size_type npos = std::string::npos; if ( filename.find('.') == npos ) { actual_filename += ".log"; } } // Check that this is not a duplicate name // change log 18 if ( stream_ps.find(actual_filename)!=stream_ps.end() ) { if (clean_slate_configuration) { // change log 22 // throw edm::Exception ( edm::errors::Configuration ) LogError("duplicateDestination") // change log 35 <<"Duplicate name for a MessageLogger Destination: " << actual_filename << "\n" << "Only the first configuration instructions are used"; continue; } else { LogWarning("duplicateDestination") <<"Duplicate name for a MessageLogger Destination: " << actual_filename << "\n" << "Only original configuration instructions are used"; continue; } } ordinary_destination_filenames.push_back(actual_filename); // attach the current destination, keeping a control handle to it: ELdestControl dest_ctrl; if( actual_filename == "cout" ) { dest_ctrl = admin_p->attach( ELoutput(std::cout) ); stream_ps["cout"] = &std::cout; } else if( actual_filename == "cerr" ) { early_dest.setThreshold(ELzeroSeverity); dest_ctrl = early_dest; stream_ps["cerr"] = &std::cerr; } else { boost::shared_ptr<std::ofstream> os_sp(new std::ofstream(actual_filename.c_str())); file_ps.push_back(os_sp); dest_ctrl = admin_p->attach( ELoutput(*os_sp) ); stream_ps[actual_filename] = os_sp.get(); } //(*errorlog_p)( ELinfo, "added_dest") << filename << endmsg; // now configure this destination: configure_dest(dest_ctrl, psetname); } // for [it = destinations.begin() to end()] } // configure_ordinary_destinations
void edm::service::MessageLoggerScribe::configure_statistics | ( | ) | [private] |
Definition at line 1035 of file MessageLoggerScribe.cc.
References admin_p, edm::service::ELadministrator::attach(), dtNoiseDBValidation_cfg::cerr, clean_slate_configuration, edm::errors::Configuration, configure_dest(), gather_cfg::cout, gather_cfg::destinations, Exception, file_ps, lut2db_cfg::filename, job_pset_p, messageLoggerDefaults, edm::service::ELdestControl::noTerminationSummary(), ordinary_destination_filenames, reset(), edm::search_all(), benchmark_cfg::statistics, statisticsDestControls, statisticsResets, stream_ps, and AlCaHLTBitMon_QueryRunRegistry::string.
Referenced by configure_errorlog().
{ vString empty_vString; String empty_String; PSet empty_PSet; // grab list of statistics destinations: vString statistics = getAparameter<vString>(*job_pset_p, "statistics", empty_vString); bool no_statistics_configured = statistics.empty(); // change log 24 if ( no_statistics_configured ) { // Read the list of staistics destinations from hardwired defaults, // but only if there is also no list of ordinary destinations. // (If a cfg specifies destinations, and no statistics, assume that // is what the user wants.) vString destinations = getAparameter<vString>(*job_pset_p, "destinations", empty_vString); if (destinations.empty()) { statistics = messageLoggerDefaults->statistics; no_statistics_configured = statistics.empty(); } } // establish each statistics destination: for( vString::const_iterator it = statistics.begin() ; it != statistics.end() ; ++it ) { String statname = *it; String psetname = statname; // check that this destination is not just a placeholder // change log 20 PSet stat_pset = getAparameter<PSet>(*job_pset_p, psetname, empty_PSet); bool is_placeholder = getAparameter<bool>(stat_pset, "placeholder", false); if (is_placeholder) continue; // Determine the destination file name String filename = getAparameter<String>(stat_pset, "output", empty_String); if ( filename == empty_String ) { filename = messageLoggerDefaults->output(psetname); // change log 31 if (filename == empty_String) { filename = statname; } } // Modify the file name if extension or name is explicitly specified // change log 14 -- probably suspenders and a belt, because ouput option // is present, but uniformity is nice. String explicit_filename = getAparameter<String>(stat_pset, "filename", filename); if (explicit_filename != empty_String) filename = explicit_filename; String explicit_extension = getAparameter<String>(stat_pset, "extension", empty_String); if (explicit_extension != empty_String) { if (explicit_extension[0] == '.') { filename += explicit_extension; } else { filename = filename + "." + explicit_extension; } } // Attach a default extension of .log if there is no extension on a file // change log 18 - this had been done in concert with attaching destination std::string actual_filename = filename; // change log 4 if ( (filename != "cout") && (filename != "cerr") ) { // change log 23 const std::string::size_type npos = std::string::npos; if ( filename.find('.') == npos ) { actual_filename += ".log"; } } // Check that this is not a duplicate name - // unless it is an ordinary destination (which stats can share) if ( !search_all(ordinary_destination_filenames, actual_filename) ) { if ( stream_ps.find(actual_filename)!=stream_ps.end() ) { if (clean_slate_configuration) { // change log 22 throw edm::Exception ( edm::errors::Configuration ) <<"Duplicate name for a MessageLogger Statistics Destination: " << actual_filename << "\n"; } else { LogWarning("duplicateDestination") <<"Duplicate name for a MessageLogger Statistics Destination: " << actual_filename << "\n" << "Only original configuration instructions are used"; continue; } } } // create (if statistics file does not match any destination file name) // or note (if statistics file matches a destination file name) the ostream. // But if no statistics destinations were provided in the config, do not // create a new destination for this hardwired statistics - only act if // it is matches a destination. (shange log 24) bool statistics_destination_is_real = !no_statistics_configured; std::ostream* os_p; if ( stream_ps.find(actual_filename) == stream_ps.end() ) { if ( actual_filename == "cout" ) { os_p = &std::cout; } else if ( actual_filename == "cerr" ) { os_p = &std::cerr; } else { boost::shared_ptr<std::ofstream> os_sp(new std::ofstream(actual_filename.c_str())); file_ps.push_back(os_sp); os_p = os_sp.get(); } stream_ps[actual_filename] = os_p; } else { statistics_destination_is_real = true; // change log 24 os_p = stream_ps[actual_filename]; } if (statistics_destination_is_real) { // change log 24 // attach the statistics destination, keeping a control handle to it: ELdestControl dest_ctrl; dest_ctrl = admin_p->attach( ELstatistics(*os_p) ); statisticsDestControls.push_back(dest_ctrl); bool reset = getAparameter<bool>(stat_pset, "reset", false); statisticsResets.push_back(reset); // now configure this destination: configure_dest(dest_ctrl, psetname); // and suppress the desire to do an extra termination summary just because // of end-of-job info messages dest_ctrl.noTerminationSummary(); } } // for [it = statistics.begin() to end()] } // configure_statistics
T edm::service::MessageLoggerScribe::getAparameter | ( | PSet const & | p, |
std::string const & | id, | ||
T const & | def | ||
) | [inline, private] |
Definition at line 162 of file MessageLoggerScribe.h.
References def, and lumiQTWidget::t.
{ T t = def; try { t = p.template getUntrackedParameter<T>(id, def); } catch (...) { try { t = p.template getParameter<T>(id); } catch (...) { // Since PSetValidation will catch such errors, we simply proceed as // best we can in case we are setting up the logger just to contain the // validation-caught error messages. } } return t; }
static ErrorLog* edm::service::MessageLoggerScribe::getErrorLog_ptr | ( | ) | [inline, static] |
Definition at line 105 of file MessageLoggerScribe.h.
References static_errorlog_p.
{return static_errorlog_p;}
void edm::service::MessageLoggerScribe::log | ( | ErrorObj * | errorobj_p | ) | [private] |
Definition at line 466 of file MessageLoggerScribe.cc.
References admin_p, ecalBxOrbitNumberGrapher_cfg::categories, edm::ErrorObj::context(), fwrapper::cs, edm::service::ELadministrator::getContextSupplier(), edm::ELextendedID::id, parseCategories(), edm::service::MsgContext::setContext(), edm::ErrorObj::setID(), and edm::ErrorObj::xid().
Referenced by configure_errorlog(), and runCommand().
{ ELcontextSupplier& cs = const_cast<ELcontextSupplier&>(admin_p->getContextSupplier()); MsgContext& mc = dynamic_cast<MsgContext&>(cs); mc.setContext(errorobj_p->context()); std::vector<std::string> categories; parseCategories(errorobj_p->xid().id, categories); for (unsigned int icat = 0; icat < categories.size(); ++icat) { errorobj_p->setID(categories[icat]); (*errorlog_p)( *errorobj_p ); // route the message text } }
void edm::service::MessageLoggerScribe::parseCategories | ( | std::string const & | s, |
std::vector< std::string > & | cats | ||
) | [private] |
Definition at line 1202 of file MessageLoggerScribe.cc.
Referenced by log().
{ const std::string::size_type npos = std::string::npos; std::string::size_type i = 0; while ( i != npos ) { std::string::size_type j = s.find('|',i); cats.push_back (s.substr(i,j-i)); i = j; while ( (i != npos) && (s[i] == '|') ) ++i; // the above handles cases of || and also | at end of string } // Note: This algorithm assigns, as desired, one null category if it // encounters an empty categories string }
void edm::service::MessageLoggerScribe::run | ( | void | ) | [virtual] |
Definition at line 243 of file MessageLoggerScribe.cc.
References done, instance, m_queue, edm::MLSCRIBE_RUNNING_INDICATOR, and runCommand().
{ MessageLoggerQ::OpCode opcode; void * operand; MessageDrop::instance()->messageLoggerScribeIsRunning = MLSCRIBE_RUNNING_INDICATOR; // ChangeLog 30 // std::cerr << "MessageLoggerScribe::run(): \n"; // std::cerr << "messageLoggerScribeIsRunning = " // << (int)MessageDrop::instance()->messageLoggerScribeIsRunning << "\n"; do { m_queue->consume(opcode, operand); // grab next work item from Q // changeLog 36 runCommand (opcode, operand); } while(! done); } // MessageLoggerScribe::run()
void edm::service::MessageLoggerScribe::runCommand | ( | MessageLoggerQ::OpCode | opcode, |
void * | operand | ||
) | [virtual] |
Reimplemented from edm::service::AbstractMLscribe.
Definition at line 263 of file MessageLoggerScribe.cc.
References active, edm::ConfigurationHandshake::c, dtNoiseDBValidation_cfg::cerr, edm::MessageLoggerQ::CONFIGURE, configure_errorlog(), configure_external_dests(), count, done, alignCSCRings::e, edm::MessageLoggerQ::END_THREAD, edm::ConfigurationHandshake::epp, Exception, edm::MessageLoggerQ::EXTERN_DEST, extern_dests, edm::MessageLoggerQ::FJR_SUMMARY, edm::MessageLoggerQ::FLUSH_LOG_Q, edm::MessageLoggerQ::GROUP_STATS, instance, job_pset_p, edm::MessageLoggerQ::JOBMODE, edm::MessageLoggerQ::JOBREPORT, jobReportOption, log(), edm::MessageLoggerQ::LOG_A_MESSAGE, edm::ConfigurationHandshake::m, messageLoggerDefaults, alignBH_cfg::mode, edm::service::ELstatistics::noteGroupedCategory(), edm::ConfigurationHandshake::p, purge_mode, edm::MessageLoggerQ::SHUT_UP, singleThread, AlCaHLTBitMon_QueryRunRegistry::string, edm::MessageLoggerQ::SUMMARIZE, triggerFJRmessageSummary(), triggerStatisticsSummaries(), and cms::Exception::what().
Referenced by run().
{ switch(opcode) { // interpret the work item default: { assert(false); // can't happen (we certainly hope!) break; } case MessageLoggerQ::END_THREAD: { assert( operand == 0 ); done = true; MessageDrop::instance()->messageLoggerScribeIsRunning = (unsigned char) -1; // ChangeLog 30 break; } case MessageLoggerQ::LOG_A_MESSAGE: { ErrorObj * errorobj_p = static_cast<ErrorObj *>(operand); try { if(active && !purge_mode) log (errorobj_p); } catch(cms::Exception& e) { ++count; std::cerr << "MessageLoggerScribe caught " << count << " cms::Exceptions, text = \n" << e.what() << "\n"; if(count > 25) { cerr << "MessageLogger will no longer be processing " << "messages due to errors (entering purge mode).\n"; purge_mode = true; } } catch(...) { std::cerr << "MessageLoggerScribe caught an unknown exception and " << "will no longer be processing " << "messages. (entering purge mode)\n"; purge_mode = true; } delete errorobj_p; // dispose of the message text break; } case MessageLoggerQ::CONFIGURE: { // changelog 17 if (singleThread) { job_pset_p.reset(static_cast<ParameterSet *>(operand)); configure_errorlog(); break; } else { ConfigurationHandshake * h_p = static_cast<ConfigurationHandshake *>(operand); job_pset_p.reset(static_cast<ParameterSet *>(h_p->p)); boost::mutex::scoped_lock sl(h_p->m); // get lock try { configure_errorlog(); } catch(edm::Exception& e) { Place_for_passing_exception_ptr epp = h_p->epp; if (!(*epp)) { *epp = boost::shared_ptr<edm::Exception>(new edm::Exception(e)); } else { Pointer_to_new_exception_on_heap ep = *epp; (*ep) << "\n and another exception: \n" << e.what(); } } // Note - since the configuring code has not made a new copy of the // job parameter set, we must not delete job_pset_p (in contrast to // the case for errorobj_p). On the other hand, if we instantiate // a new edm::Exception pointed to by *epp, it is the responsibility // of the MessageLoggerQ to delete it. h_p->c.notify_all(); // Signal to MessageLoggerQ that we are done // finally, release the scoped lock by letting it go out of scope break; } } case MessageLoggerQ::EXTERN_DEST: { try { extern_dests.push_back( static_cast<NamedDestination *>(operand) ); configure_external_dests(); } catch(cms::Exception& e) // change log 21 { std::cerr << "MessageLoggerScribe caught a cms::Exception " << "during extern dest configuration:\n" << e.what() << "\n" << "This is a serious problem, and the extern dest " << "will not be produced.\n" << "However, the rest of the logger continues to run.\n"; } catch(...) // change log 21 { std::cerr << "MessageLoggerScribe caught unkonwn exception type\n" << "during extern dest configuration. " << "This is a serious problem, and the extern dest " << "will not be produced.\n" << "The rest of the logger will attempt to continue to run.\n"; } break; } case MessageLoggerQ::SUMMARIZE: { assert( operand == 0 ); try { triggerStatisticsSummaries(); } catch(cms::Exception& e) { std::cerr << "MessageLoggerScribe caught exception " << "during summarize:\n" << e.what() << "\n"; } catch(...) { std::cerr << "MessageLoggerScribe caught unkonwn exception type " << "during summarize. (Ignored)\n"; } break; } case MessageLoggerQ::JOBREPORT: { // change log 19 std::string* jobReportOption_p = static_cast<std::string*>(operand); try { jobReportOption = *jobReportOption_p; } catch(cms::Exception& e) { std::cerr << "MessageLoggerScribe caught a cms::Exception " << "during processing of --jobReport option:\n" << e.what() << "\n" << "This likely will affect or prevent the job report.\n" << "However, the rest of the logger continues to run.\n"; } catch(...) { std::cerr << "MessageLoggerScribe caught unkonwn exception type\n" << "during processing of --jobReport option.\n" << "This likely will affect or prevent the job report.\n" << "However, the rest of the logger continues to run.\n"; } delete jobReportOption_p; // dispose of the message text // which will have been new-ed // in MessageLogger.cc (service version) break; } case MessageLoggerQ::JOBMODE: { // change log 24 std::string* jobMode_p = static_cast<std::string*>(operand); JobMode jm = MessageLoggerDefaults::mode(*jobMode_p); messageLoggerDefaults = value_ptr<MessageLoggerDefaults>(new MessageLoggerDefaults(jm)); // Note - since messageLoggerDefaults is a value_ptr, // there is no concern about deleting here. delete jobMode_p; // dispose of the message text // which will have been new-ed // in MessageLogger.cc (service version) break; } case MessageLoggerQ::SHUT_UP: { assert( operand == 0 ); active = false; break; } case MessageLoggerQ::FLUSH_LOG_Q: { // changelog 26 if (singleThread) return; ConfigurationHandshake * h_p = static_cast<ConfigurationHandshake *>(operand); job_pset_p.reset(static_cast<ParameterSet *>(h_p->p)); boost::mutex::scoped_lock sl(h_p->m); // get lock h_p->c.notify_all(); // Signal to MessageLoggerQ that we are done // finally, release the scoped lock by letting it go out of scope break; } case MessageLoggerQ::GROUP_STATS: { // change log 27 std::string* cat_p = static_cast<std::string*>(operand); ELstatistics::noteGroupedCategory(*cat_p); delete cat_p; // dispose of the message text break; } case MessageLoggerQ::FJR_SUMMARY: { // changelog 29 if (singleThread) { std::map<std::string, double> * smp = static_cast<std::map<std::string, double> *>(operand); triggerFJRmessageSummary(*smp); break; } else { ConfigurationHandshake * h_p = static_cast<ConfigurationHandshake *>(operand); boost::mutex::scoped_lock sl(h_p->m); // get lock std::map<std::string, double> * smp = static_cast<std::map<std::string, double> *>(h_p->p); triggerFJRmessageSummary(*smp); h_p->c.notify_all(); // Signal to MessageLoggerQ that we are done // finally, release the scoped lock by letting it go out of scope break; } } } // switch } // MessageLoggerScribe::runCommand(opcode, operand)
void edm::service::MessageLoggerScribe::setStaticErrorLog_ptr | ( | ) | [inline, private] |
Definition at line 225 of file MessageLoggerScribe.h.
References errorlog_p, and static_errorlog_p.
{static_errorlog_p = errorlog_p.get();}
void edm::service::MessageLoggerScribe::triggerFJRmessageSummary | ( | std::map< std::string, double > & | sm | ) | [private] |
Definition at line 1229 of file MessageLoggerScribe.cc.
References statisticsDestControls.
Referenced by runCommand().
{ if (statisticsDestControls.empty()) { sm["NoStatisticsDestinationsConfigured"] = 0.0; } else { statisticsDestControls[0].summaryForJobReport(sm); } }
void edm::service::MessageLoggerScribe::triggerStatisticsSummaries | ( | ) | [private] |
Definition at line 1219 of file MessageLoggerScribe.cc.
References i, statisticsDestControls, and statisticsResets.
Referenced by runCommand().
{ assert (statisticsDestControls.size() == statisticsResets.size()); for (unsigned int i = 0; i != statisticsDestControls.size(); ++i) { statisticsDestControls[i].summary( ); if (statisticsResets[i]) statisticsDestControls[i].wipe( ); } }
bool edm::service::MessageLoggerScribe::active [private] |
Definition at line 243 of file MessageLoggerScribe.h.
Referenced by runCommand().
Definition at line 228 of file MessageLoggerScribe.h.
Referenced by configure_external_dests(), configure_fwkJobReports(), configure_ordinary_destinations(), configure_statistics(), log(), MessageLoggerScribe(), and ~MessageLoggerScribe().
bool edm::service::MessageLoggerScribe::clean_slate_configuration [private] |
Definition at line 241 of file MessageLoggerScribe.h.
Referenced by configure_errorlog(), configure_fwkJobReports(), configure_ordinary_destinations(), and configure_statistics().
int edm::service::MessageLoggerScribe::count [private] |
Definition at line 247 of file MessageLoggerScribe.h.
Referenced by runCommand().
bool edm::service::MessageLoggerScribe::done [private] |
Definition at line 245 of file MessageLoggerScribe.h.
Referenced by run(), and runCommand().
Definition at line 229 of file MessageLoggerScribe.h.
Referenced by configure_errorlog(), and configure_ordinary_destinations().
boost::shared_ptr<ErrorLog> edm::service::MessageLoggerScribe::errorlog_p [private] |
Definition at line 230 of file MessageLoggerScribe.h.
Referenced by setStaticErrorLog_ptr().
std::vector<NamedDestination *> edm::service::MessageLoggerScribe::extern_dests [private] |
Definition at line 234 of file MessageLoggerScribe.h.
Referenced by configure_external_dests(), runCommand(), and ~MessageLoggerScribe().
std::vector<boost::shared_ptr<std::ofstream> > edm::service::MessageLoggerScribe::file_ps [private] |
Definition at line 231 of file MessageLoggerScribe.h.
Referenced by configure_fwkJobReports(), configure_ordinary_destinations(), and configure_statistics().
boost::shared_ptr<PSet> edm::service::MessageLoggerScribe::job_pset_p [private] |
Definition at line 233 of file MessageLoggerScribe.h.
Referenced by configure_dest(), configure_errorlog(), configure_external_dests(), configure_fwkJobReports(), configure_ordinary_destinations(), configure_statistics(), and runCommand().
std::string edm::service::MessageLoggerScribe::jobReportOption [private] |
Definition at line 239 of file MessageLoggerScribe.h.
Referenced by configure_fwkJobReports(), and runCommand().
boost::shared_ptr<ThreadQueue> edm::service::MessageLoggerScribe::m_queue [private] |
Definition at line 248 of file MessageLoggerScribe.h.
Referenced by configure_errorlog(), and run().
Definition at line 242 of file MessageLoggerScribe.h.
Referenced by configure_dest(), configure_fwkJobReports(), configure_ordinary_destinations(), configure_statistics(), and runCommand().
Definition at line 232 of file MessageLoggerScribe.h.
Referenced by MessageLoggerScribe().
std::vector<String> edm::service::MessageLoggerScribe::ordinary_destination_filenames [private] |
Definition at line 236 of file MessageLoggerScribe.h.
Referenced by configure_ordinary_destinations(), and configure_statistics().
bool edm::service::MessageLoggerScribe::purge_mode [private] |
Definition at line 246 of file MessageLoggerScribe.h.
Referenced by runCommand().
bool edm::service::MessageLoggerScribe::singleThread [private] |
Definition at line 244 of file MessageLoggerScribe.h.
Referenced by configure_errorlog(), and runCommand().
ErrorLog * edm::service::MessageLoggerScribe::static_errorlog_p [static, private] |
Definition at line 240 of file MessageLoggerScribe.h.
Referenced by getErrorLog_ptr(), and setStaticErrorLog_ptr().
std::vector<ELdestControl> edm::service::MessageLoggerScribe::statisticsDestControls [private] |
Definition at line 237 of file MessageLoggerScribe.h.
Referenced by configure_statistics(), triggerFJRmessageSummary(), and triggerStatisticsSummaries().
std::vector<bool> edm::service::MessageLoggerScribe::statisticsResets [private] |
Definition at line 238 of file MessageLoggerScribe.h.
Referenced by configure_statistics(), and triggerStatisticsSummaries().
std::map<String,std::ostream *> edm::service::MessageLoggerScribe::stream_ps [private] |
Definition at line 235 of file MessageLoggerScribe.h.
Referenced by configure_errorlog(), configure_fwkJobReports(), configure_ordinary_destinations(), and configure_statistics().