CMS 3D CMS Logo

List of all members | Public Member Functions | Private Types | Private Member Functions | Private Attributes
edm::service::MessageLoggerScribe Class Reference

#include <MessageLoggerScribe.h>

Inheritance diagram for edm::service::MessageLoggerScribe:
edm::service::AbstractMLscribe

Public Member Functions

 MessageLoggerScribe (std::shared_ptr< ThreadQueue > queue)
 — If queue is NULL, this sets singleThread true More...
 
virtual void run ()
 
void runCommand (MessageLoggerQ::OpCode opcode, void *operand) override
 
 ~MessageLoggerScribe () override
 
- Public Member Functions inherited from edm::service::AbstractMLscribe
 AbstractMLscribe ()
 
virtual ~AbstractMLscribe ()
 

Private Types

typedef ParameterSet PSet
 
typedef std::string String
 
typedef std::vector< StringvString
 

Private Member Functions

void configure_dest (std::shared_ptr< ELdestination > dest_ctrl, String const &filename)
 
void configure_errorlog ()
 
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 triggerFJRmessageSummary (std::map< std::string, double > &sm)
 
void triggerStatisticsSummaries ()
 

Private Attributes

bool active
 
edm::propagate_const< std::shared_ptr< ELadministrator > > admin_p
 
bool clean_slate_configuration
 
int count
 
bool done
 
std::shared_ptr< ELdestinationearly_dest
 
std::vector< edm::propagate_const< std::shared_ptr< std::ofstream > > > file_ps
 
edm::propagate_const< std::shared_ptr< PSet > > job_pset_p
 
edm::propagate_const< std::shared_ptr< ThreadQueue > > m_queue
 
value_ptr< MessageLoggerDefaultsmessageLoggerDefaults
 
std::vector< Stringordinary_destination_filenames
 
bool purge_mode
 
bool singleThread
 
std::vector< std::shared_ptr< ELstatistics > > statisticsDestControls
 
std::vector< bool > statisticsResets
 
std::map< String, edm::propagate_const< std::ostream * > > stream_ps
 

Detailed Description

Definition at line 86 of file MessageLoggerScribe.h.

Member Typedef Documentation

Definition at line 106 of file MessageLoggerScribe.h.

typedef std::string edm::service::MessageLoggerScribe::String
private

Definition at line 104 of file MessageLoggerScribe.h.

typedef std::vector<String> edm::service::MessageLoggerScribe::vString
private

Definition at line 105 of file MessageLoggerScribe.h.

Constructor & Destructor Documentation

edm::service::MessageLoggerScribe::MessageLoggerScribe ( std::shared_ptr< ThreadQueue queue)
explicit

— If queue is NULL, this sets singleThread true

Definition at line 212 of file MessageLoggerScribe.cc.

213  : admin_p(new ELadministrator()),
214  early_dest(admin_p->attach(std::make_shared<ELoutput>(std::cerr, false))),
215  file_ps(),
216  job_pset_p(),
218  active(true),
219  singleThread(queue.get() == nullptr) // changeLog 36
220  ,
221  done(false) // changeLog 32
222  ,
223  purge_mode(false) // changeLog 32
224  ,
225  count(false) // changeLog 32
226  ,
227  m_queue(queue) // changeLog 36
228  {}
edm::propagate_const< std::shared_ptr< ELadministrator > > admin_p
std::vector< edm::propagate_const< std::shared_ptr< std::ofstream > > > file_ps
std::shared_ptr< ELdestination > early_dest
edm::propagate_const< std::shared_ptr< PSet > > job_pset_p
edm::propagate_const< std::shared_ptr< ThreadQueue > > m_queue
edm::service::MessageLoggerScribe::~MessageLoggerScribe ( )
override

Definition at line 230 of file MessageLoggerScribe.cc.

References admin_p.

230 { admin_p->finish(); }
edm::propagate_const< std::shared_ptr< ELadministrator > > admin_p

Member Function Documentation

void edm::service::MessageLoggerScribe::configure_dest ( std::shared_ptr< ELdestination dest_ctrl,
String const &  filename 
)
private

Definition at line 426 of file MessageLoggerScribe.cc.

References myMessageLogger_cff::categories, taus_updatedMVAIds_cff::category, edm::copy_all(), edm::MessageDrop::debugAlwaysSuppressed, edm::ELseverityLevel::ELsev_info, edm::ELseverityLevel::ELsev_success, edm::ELseverityLevel::ELsev_warning, corrVsCorr::filename, edm::MessageDrop::infoAlwaysSuppressed, job_pset_p, MessageLogger_cfi::limit, messageLoggerDefaults, MessageLogger_cfi::noLineBreaks, ErrorSummaryFilter_cfi::severity, AlCaHLTBitMon_QueryRunRegistry::string, and edm::MessageDrop::warningAlwaysSuppressed.

Referenced by configure_ordinary_destinations(), and configure_statistics().

426  {
427  static const int NO_VALUE_SET = -45654; // change log 2
428  vString empty_vString;
429  PSet empty_PSet;
430  String empty_String;
431 
432  // Defaults: // change log 3a
433  const std::string COMMON_DEFAULT_THRESHOLD = "INFO";
434  const int COMMON_DEFAULT_LIMIT = NO_VALUE_SET;
435  const int COMMON_DEFAULT_INTERVAL = NO_VALUE_SET; // change log 6
436  const int COMMON_DEFAULT_TIMESPAN = NO_VALUE_SET;
437 
438  char const* severity_array[] = {"WARNING", "INFO", "ERROR", "DEBUG"};
439  vString const severities(severity_array + 0, severity_array + 4);
440 
441  // grab list of categories
442  vString categories = getAparameter<vString>(*job_pset_p, "categories", empty_vString);
443 
444  // grab list of messageIDs -- these are a synonym for categories
445  // Note -- the use of messageIDs is deprecated in favor of categories
446  {
447  vString messageIDs = getAparameter<vString>(*job_pset_p, "messageIDs", empty_vString);
448 
449  // combine the lists, not caring about possible duplicates (for now)
450  copy_all(messageIDs, std::back_inserter(categories));
451  } // no longer need messageIDs
452 
453  // grab list of hardwired categories (hardcats) -- these are to be added
454  // to the list of categories -- change log 24
455  {
456  std::vector<std::string> hardcats = messageLoggerDefaults->categories;
457  // combine the lists, not caring about possible duplicates (for now)
458  copy_all(hardcats, std::back_inserter(categories));
459  } // no longer need hardcats
460 
461  // grab default threshold common to all destinations
462  String default_threshold = getAparameter<String>(*job_pset_p, "threshold", empty_String);
463  // change log 3a
464  // change log 24
465 
466  // grab default limit/interval/timespan common to all destinations/categories:
467  PSet default_pset = getAparameter<PSet>(*job_pset_p, "default", empty_PSet);
468  int default_limit = getAparameter<int>(default_pset, "limit", COMMON_DEFAULT_LIMIT);
469  int default_interval = getAparameter<int>(default_pset, "reportEvery", COMMON_DEFAULT_INTERVAL);
470  // change log 6, 10
471  int default_timespan = getAparameter<int>(default_pset, "timespan", COMMON_DEFAULT_TIMESPAN);
472  // change log 2a
473  // change log 3a
474  String default_pset_threshold = getAparameter<String>(default_pset, "threshold", default_threshold);
475  // change log 34
476 
477  // grab all of this destination's parameters:
478  PSet dest_pset = getAparameter<PSet>(*job_pset_p, filename, empty_PSet);
479 
480  // See if this is just a placeholder // change log 9
481  bool is_placeholder = getAparameter<bool>(dest_pset, "placeholder", false);
482  if (is_placeholder)
483  return;
484 
485  // grab this destination's default limit/interval/timespan:
486  PSet dest_default_pset = getAparameter<PSet>(dest_pset, "default", empty_PSet);
487  int dest_default_limit = getAparameter<int>(dest_default_pset, "limit", default_limit);
488  int dest_default_interval = getAparameter<int>(dest_default_pset, "reportEvery", default_interval);
489  // change log 6
490  int dest_default_timespan = getAparameter<int>(dest_default_pset, "timespan", default_timespan);
491  // change log 1a
492  if (dest_default_limit != NO_VALUE_SET) {
493  if (dest_default_limit < 0)
494  dest_default_limit = 2000000000;
495  dest_ctrl->setLimit("*", dest_default_limit);
496  } // change log 1b, 2a, 2b
497  if (dest_default_interval != NO_VALUE_SET) { // change log 6
498  dest_ctrl->setInterval("*", dest_default_interval);
499  }
500  if (dest_default_timespan != NO_VALUE_SET) {
501  if (dest_default_timespan < 0)
502  dest_default_timespan = 2000000000;
503  dest_ctrl->setTimespan("*", dest_default_timespan);
504  } // change log 1b, 2a, 2b
505 
506  // establish this destination's threshold:
507  String dest_threshold = getAparameter<String>(dest_pset, "threshold", default_threshold);
508  if (dest_threshold == empty_String) {
509  dest_threshold = default_threshold;
510  }
511  if (dest_threshold == empty_String) { // change log 34
512  dest_threshold = default_pset_threshold;
513  }
514  if (dest_threshold == empty_String) {
515  dest_threshold = messageLoggerDefaults->threshold(filename);
516  }
517  if (dest_threshold == empty_String)
518  dest_threshold = COMMON_DEFAULT_THRESHOLD;
519  ELseverityLevel threshold_sev(dest_threshold);
520  dest_ctrl->setThreshold(threshold_sev);
521  // change log 37
522  if (threshold_sev <= ELseverityLevel::ELsev_success) {
524  }
525  if (threshold_sev <= ELseverityLevel::ELsev_info) {
527  }
528  if (threshold_sev <= ELseverityLevel::ELsev_warning) {
530  }
531 
532  // establish this destination's limit/interval/timespan for each category:
533  for (vString::const_iterator id_it = categories.begin(); id_it != categories.end(); ++id_it) {
534  String msgID = *id_it;
535  PSet default_category_pset = getAparameter<PSet>(default_pset, msgID, empty_PSet); // change log 5
536  PSet category_pset = getAparameter<PSet>(dest_pset, msgID, default_category_pset);
537 
538  int category_default_limit = getAparameter<int>(default_category_pset, "limit", NO_VALUE_SET);
539  int limit = getAparameter<int>(category_pset, "limit", category_default_limit);
540  if (limit == NO_VALUE_SET)
541  limit = dest_default_limit;
542  // change log 7
543  int category_default_interval = getAparameter<int>(default_category_pset, "reportEvery", NO_VALUE_SET);
544  int interval = getAparameter<int>(category_pset, "reportEvery", category_default_interval);
545  if (interval == NO_VALUE_SET)
546  interval = dest_default_interval;
547  // change log 6 and then 7
548  int category_default_timespan = getAparameter<int>(default_category_pset, "timespan", NO_VALUE_SET);
549  int timespan = getAparameter<int>(category_pset, "timespan", category_default_timespan);
550  if (timespan == NO_VALUE_SET)
551  timespan = dest_default_timespan;
552  // change log 7
553 
554  const std::string& category = msgID;
555  if (limit == NO_VALUE_SET) { // change log 24
556  limit = messageLoggerDefaults->limit(filename, category);
557  }
558  if (interval == NO_VALUE_SET) { // change log 24
559  interval = messageLoggerDefaults->reportEvery(filename, category);
560  }
561  if (timespan == NO_VALUE_SET) { // change log 24
562  timespan = messageLoggerDefaults->timespan(filename, category);
563  }
564 
565  if (limit != NO_VALUE_SET) {
566  if (limit < 0)
567  limit = 2000000000;
568  dest_ctrl->setLimit(msgID, limit);
569  } // change log 2a, 2b
570  if (interval != NO_VALUE_SET) {
571  dest_ctrl->setInterval(msgID, interval);
572  } // change log 6
573  if (timespan != NO_VALUE_SET) {
574  if (timespan < 0)
575  timespan = 2000000000;
576  dest_ctrl->setTimespan(msgID, timespan);
577  } // change log 2a, 2b
578 
579  } // for
580 
581  // establish this destination's limit for each severity:
582  for (vString::const_iterator sev_it = severities.begin(); sev_it != severities.end(); ++sev_it) {
583  String sevID = *sev_it;
584  ELseverityLevel severity(sevID);
585  PSet default_sev_pset = getAparameter<PSet>(default_pset, sevID, empty_PSet);
586  PSet sev_pset = getAparameter<PSet>(dest_pset, sevID, default_sev_pset);
587  // change log 5
588  int limit = getAparameter<int>(sev_pset, "limit", NO_VALUE_SET);
589  if (limit == NO_VALUE_SET) { // change log 24
590  limit = messageLoggerDefaults->sev_limit(filename, sevID);
591  }
592  if (limit != NO_VALUE_SET) {
593  if (limit < 0)
594  limit = 2000000000; // change log 38
595  dest_ctrl->setLimit(severity, limit);
596  }
597  int interval = getAparameter<int>(sev_pset, "reportEvery", NO_VALUE_SET);
598  if (interval == NO_VALUE_SET) { // change log 24
599  interval = messageLoggerDefaults->sev_reportEvery(filename, sevID);
600  }
601  if (interval != NO_VALUE_SET)
602  dest_ctrl->setInterval(severity, interval);
603  // change log 2
604  int timespan = getAparameter<int>(sev_pset, "timespan", NO_VALUE_SET);
605  if (timespan == NO_VALUE_SET) { // change log 24
606  timespan = messageLoggerDefaults->sev_timespan(filename, sevID);
607  }
608  if (timespan != NO_VALUE_SET) {
609  if (timespan < 0)
610  timespan = 2000000000; // change log 38
611  dest_ctrl->setTimespan(severity, timespan);
612  }
613  } // for
614 
615  // establish this destination's linebreak policy:
616  bool noLineBreaks_default = getAparameter<bool>(default_pset, "noLineBreaks", false);
617  // change log 5
618  bool noLineBreaks = getAparameter<bool>(dest_pset, "noLineBreaks", noLineBreaks_default);
619  if (noLineBreaks) {
620  dest_ctrl->setLineLength(32000);
621  } else {
622  int lenDef = 80;
623  int lineLen_default = getAparameter<int>(default_pset, "lineLength", lenDef);
624  // change log 5
625  int lineLen = getAparameter<int>(dest_pset, "lineLength", lineLen_default);
626  if (lineLen != lenDef) {
627  dest_ctrl->setLineLength(lineLen);
628  }
629  }
630 
631  // if indicated, suppress time stamps in this destination's output
632  bool suppressTime_default = getAparameter<bool>(default_pset, "noTimeStamps", false);
633  bool suppressTime = getAparameter<bool>(dest_pset, "noTimeStamps", suppressTime_default);
634  if (suppressTime) {
635  dest_ctrl->suppressTime();
636  }
637 
638  } // MessageLoggerScribe::configure_dest()
static bool debugAlwaysSuppressed
Definition: MessageDrop.h:109
static bool warningAlwaysSuppressed
Definition: MessageDrop.h:111
edm::propagate_const< std::shared_ptr< PSet > > job_pset_p
Func copy_all(ForwardSequence &s, Func f)
wrappers for copy
Definition: Algorithms.h:20
static bool infoAlwaysSuppressed
Definition: MessageDrop.h:110
value_ptr< MessageLoggerDefaults > messageLoggerDefaults
void edm::service::MessageLoggerScribe::configure_errorlog ( )
private

Definition at line 392 of file MessageLoggerScribe.cc.

References clean_slate_configuration, configure_ordinary_destinations(), configure_statistics(), early_dest, job_pset_p, log(), edm::MessageLoggerQ::LOG_A_MESSAGE, m_queue, singleThread, and stream_ps.

Referenced by runCommand().

392  {
393  vString empty_vString;
394  String empty_String;
395  PSet empty_PSet;
396 
397  // The following is present to test pre-configuration message handling:
398  String preconfiguration_message =
399  getAparameter<String>(*job_pset_p, "generate_preconfiguration_message", empty_String);
400  if (preconfiguration_message != empty_String) {
401  // To test a preconfiguration message without first going thru the
402  // configuration we are about to do, we issue the message (so it sits
403  // on the queue), then copy the processing that the LOG_A_MESSAGE case
404  // does. We suppress the timestamp to allow for automated unit testing.
405  early_dest->suppressTime();
406  LogError("preconfiguration") << preconfiguration_message;
407  if (!singleThread) {
408  MessageLoggerQ::OpCode opcode;
409  void* operand;
410  m_queue->consume(opcode, operand); // grab next work item from Q
411  assert(opcode == MessageLoggerQ::LOG_A_MESSAGE);
412  ErrorObj* errorobj_p = static_cast<ErrorObj*>(operand);
413  log(errorobj_p);
414  delete errorobj_p; // dispose of the message text
415  }
416  }
417 
418  if (!stream_ps.empty()) {
419  LogWarning("multiLogConfig") << "The message logger has been configured multiple times";
420  clean_slate_configuration = false; // Change Log 22
421  }
422  configure_ordinary_destinations(); // Change Log 16
423  configure_statistics(); // Change Log 16
424  } // MessageLoggerScribe::configure_errorlog()
std::map< String, edm::propagate_const< std::ostream * > > stream_ps
std::shared_ptr< ELdestination > early_dest
edm::propagate_const< std::shared_ptr< PSet > > job_pset_p
edm::propagate_const< std::shared_ptr< ThreadQueue > > m_queue
void edm::service::MessageLoggerScribe::configure_ordinary_destinations ( )
private

Definition at line 640 of file MessageLoggerScribe.cc.

References admin_p, MessageLogger_cfi::cerr, clean_slate_configuration, configure_dest(), gather_cfg::cout, edm::MessageDrop::debugAlwaysSuppressed, myMessageLogger_cff::destinations, early_dest, edm::ELhighestSeverity, edm::ELzeroSeverity, file_ps, corrVsCorr::filename, edm::MessageDrop::infoAlwaysSuppressed, job_pset_p, messageLoggerDefaults, ordinary_destination_filenames, stream_ps, AlCaHLTBitMon_QueryRunRegistry::string, and edm::MessageDrop::warningAlwaysSuppressed.

Referenced by configure_errorlog().

641  {
642  vString empty_vString;
643  String empty_String;
644  PSet empty_PSet;
645 
646  // Initialize unversal suppression variables
647  MessageDrop::debugAlwaysSuppressed = true; // change log 37
648  MessageDrop::infoAlwaysSuppressed = true; // change log 37
649  MessageDrop::warningAlwaysSuppressed = true; // change log 37
650 
651  // grab list of destinations:
652  vString destinations = getAparameter<vString>(*job_pset_p, "destinations", empty_vString);
653 
654  // Use the default list of destinations if and only if the grabbed list is
655  // empty // change log 24
656  if (destinations.empty()) {
657  destinations = messageLoggerDefaults->destinations;
658  }
659 
660  // dial down the early destination if other dest's are supplied:
661  if (!destinations.empty())
662  early_dest->setThreshold(ELhighestSeverity);
663 
664  // establish each destination:
665  for (vString::const_iterator it = destinations.begin(); it != destinations.end(); ++it) {
666  String filename = *it;
667  String psetname = filename;
668 
669  // check that this destination is not just a placeholder // change log 11
670  PSet dest_pset = getAparameter<PSet>(*job_pset_p, psetname, empty_PSet);
671  bool is_placeholder = getAparameter<bool>(dest_pset, "placeholder", false);
672  if (is_placeholder)
673  continue;
674 
675  // Modify the file name if extension or name is explicitly specified
676  // change log 14
677 
678  // Although for an ordinary destination there is no output attribute
679  // for the cfg (you can use filename instead) we provide output() for
680  // uniformity with the statistics destinations. The "right way" to
681  // work this would have been to provide a filename() method, along with
682  // an extension() method. We recognize the potential name confusion here
683  // (filename(filename))!
684 
685  // Determine the destination file name to use if no explicit filename is
686  // supplied in the cfg.
687  String filename_default = getAparameter<String>(dest_pset, "output", empty_String);
688  if (filename_default == empty_String) {
689  filename_default = messageLoggerDefaults->output(psetname); // change log 31
690  if (filename_default == empty_String) {
691  filename_default = filename;
692  }
693  }
694 
695  String explicit_filename = getAparameter<String>(dest_pset, "filename", filename_default);
696  if (explicit_filename != empty_String)
697  filename = explicit_filename;
698  String explicit_extension = getAparameter<String>(dest_pset, "extension", empty_String);
699  if (explicit_extension != empty_String) {
700  if (explicit_extension[0] == '.') {
701  filename += explicit_extension;
702  } else {
703  filename = filename + "." + explicit_extension;
704  }
705  }
706 
707  // Attach a default extension of .log if there is no extension on a file
708  // change log 18 - this had been done in concert with attaching destination
709 
710  std::string actual_filename = filename; // change log 4
711  if ((filename != "cout") && (filename != "cerr")) {
712  const std::string::size_type npos = std::string::npos;
713  if (filename.find('.') == npos) {
714  actual_filename += ".log";
715  }
716  }
717 
718  // Check that this is not a duplicate name // change log 18
719  if (stream_ps.find(actual_filename) != stream_ps.end()) {
720  if (clean_slate_configuration) { // change log 22
721  // throw edm::Exception ( edm::errors::Configuration )
722  LogError("duplicateDestination") // change log 35
723  << "Duplicate name for a MessageLogger Destination: " << actual_filename << "\n"
724  << "Only the first configuration instructions are used";
725  continue;
726  } else {
727  LogWarning("duplicateDestination")
728  << "Duplicate name for a MessageLogger Destination: " << actual_filename << "\n"
729  << "Only original configuration instructions are used";
730  continue;
731  }
732  }
733 
734  ordinary_destination_filenames.push_back(actual_filename);
735 
736  // attach the current destination, keeping a control handle to it:
737  std::shared_ptr<ELdestination> dest_ctrl;
738  if (actual_filename == "cout") {
739  dest_ctrl = std::make_shared<ELoutput>(std::cout);
740  admin_p->attach(dest_ctrl);
741  stream_ps["cout"] = &std::cout;
742  } else if (actual_filename == "cerr") {
743  early_dest->setThreshold(ELzeroSeverity);
744  dest_ctrl = early_dest;
745  stream_ps["cerr"] = &std::cerr;
746  } else {
747  auto os_sp = std::make_shared<std::ofstream>(actual_filename.c_str());
748  file_ps.push_back(os_sp);
749  dest_ctrl = std::make_shared<ELoutput>(*os_sp);
750  admin_p->attach(dest_ctrl);
751  stream_ps[actual_filename] = os_sp.get();
752  }
753 
754  // now configure this destination:
755  configure_dest(dest_ctrl, psetname);
756 
757  } // for [it = destinations.begin() to end()]
758 
759  } // configure_ordinary_destinations
ELslProxy< ELhighestSeverityGen > const ELhighestSeverity
uint16_t size_type
std::vector< String > ordinary_destination_filenames
static bool debugAlwaysSuppressed
Definition: MessageDrop.h:109
std::map< String, edm::propagate_const< std::ostream * > > stream_ps
edm::propagate_const< std::shared_ptr< ELadministrator > > admin_p
ELslProxy< ELzeroSeverityGen > const ELzeroSeverity
void configure_dest(std::shared_ptr< ELdestination > dest_ctrl, String const &filename)
std::vector< edm::propagate_const< std::shared_ptr< std::ofstream > > > file_ps
std::shared_ptr< ELdestination > early_dest
static bool warningAlwaysSuppressed
Definition: MessageDrop.h:111
edm::propagate_const< std::shared_ptr< PSet > > job_pset_p
static bool infoAlwaysSuppressed
Definition: MessageDrop.h:110
value_ptr< MessageLoggerDefaults > messageLoggerDefaults
void edm::service::MessageLoggerScribe::configure_statistics ( )
private

Definition at line 761 of file MessageLoggerScribe.cc.

References admin_p, MessageLogger_cfi::cerr, clean_slate_configuration, edm::errors::Configuration, configure_dest(), gather_cfg::cout, myMessageLogger_cff::destinations, Exception, file_ps, corrVsCorr::filename, job_pset_p, messageLoggerDefaults, ordinary_destination_filenames, reset(), edm::search_all(), myMessageLogger_cff::statistics, statisticsDestControls, statisticsResets, stream_ps, and AlCaHLTBitMon_QueryRunRegistry::string.

Referenced by configure_errorlog().

761  {
762  vString empty_vString;
763  String empty_String;
764  PSet empty_PSet;
765 
766  // grab list of statistics destinations:
767  vString statistics = getAparameter<vString>(*job_pset_p, "statistics", empty_vString);
768 
769  bool no_statistics_configured = statistics.empty(); // change log 24
770 
771  if (no_statistics_configured) {
772  // Read the list of staistics destinations from hardwired defaults,
773  // but only if there is also no list of ordinary destinations.
774  // (If a cfg specifies destinations, and no statistics, assume that
775  // is what the user wants.)
776  vString destinations = getAparameter<vString>(*job_pset_p, "destinations", empty_vString);
777  if (destinations.empty()) {
778  statistics = messageLoggerDefaults->statistics;
779  no_statistics_configured = statistics.empty();
780  }
781  }
782 
783  // establish each statistics destination:
784  for (vString::const_iterator it = statistics.begin(); it != statistics.end(); ++it) {
785  String statname = *it;
786  const String& psetname = statname;
787 
788  // check that this destination is not just a placeholder // change log 20
789  PSet stat_pset = getAparameter<PSet>(*job_pset_p, psetname, empty_PSet);
790  bool is_placeholder = getAparameter<bool>(stat_pset, "placeholder", false);
791  if (is_placeholder)
792  continue;
793 
794  // Determine the destination file name
795  String filename = getAparameter<String>(stat_pset, "output", empty_String);
796  if (filename == empty_String) {
797  filename = messageLoggerDefaults->output(psetname); // change log 31
798  if (filename == empty_String) {
799  filename = statname;
800  }
801  }
802 
803  // Modify the file name if extension or name is explicitly specified
804  // change log 14 -- probably suspenders and a belt, because ouput option
805  // is present, but uniformity is nice.
806 
807  String explicit_filename = getAparameter<String>(stat_pset, "filename", filename);
808  if (explicit_filename != empty_String)
809  filename = explicit_filename;
810  String explicit_extension = getAparameter<String>(stat_pset, "extension", empty_String);
811  if (explicit_extension != empty_String) {
812  if (explicit_extension[0] == '.') {
813  filename += explicit_extension;
814  } else {
815  filename = filename + "." + explicit_extension;
816  }
817  }
818 
819  // Attach a default extension of .log if there is no extension on a file
820  // change log 18 - this had been done in concert with attaching destination
821 
822  std::string actual_filename = filename; // change log 4
823  if ((filename != "cout") && (filename != "cerr")) { // change log 23
824  const std::string::size_type npos = std::string::npos;
825  if (filename.find('.') == npos) {
826  actual_filename += ".log";
827  }
828  }
829 
830  // Check that this is not a duplicate name -
831  // unless it is an ordinary destination (which stats can share)
832  if (!search_all(ordinary_destination_filenames, actual_filename)) {
833  if (stream_ps.find(actual_filename) != stream_ps.end()) {
834  if (clean_slate_configuration) { // change log 22
836  << "Duplicate name for a MessageLogger Statistics Destination: " << actual_filename << "\n";
837  } else {
838  LogWarning("duplicateDestination")
839  << "Duplicate name for a MessageLogger Statistics Destination: " << actual_filename << "\n"
840  << "Only original configuration instructions are used";
841  continue;
842  }
843  }
844  }
845 
846  // create (if statistics file does not match any destination file name)
847  // or note (if statistics file matches a destination file name) the ostream.
848  // But if no statistics destinations were provided in the config, do not
849  // create a new destination for this hardwired statistics - only act if
850  // it is matches a destination. (shange log 24)
851  bool statistics_destination_is_real = !no_statistics_configured;
852  std::ostream* os_p;
853  if (stream_ps.find(actual_filename) == stream_ps.end()) {
854  if (actual_filename == "cout") {
855  os_p = &std::cout;
856  } else if (actual_filename == "cerr") {
857  os_p = &std::cerr;
858  } else {
859  auto os_sp = std::make_shared<std::ofstream>(actual_filename.c_str());
860  file_ps.push_back(os_sp);
861  os_p = os_sp.get();
862  }
863  stream_ps[actual_filename] = os_p;
864  } else {
865  statistics_destination_is_real = true; // change log 24
866  os_p = stream_ps[actual_filename];
867  }
868 
869  if (statistics_destination_is_real) { // change log 24
870  // attach the statistics destination, keeping a control handle to it:
871  auto stat = std::make_shared<ELstatistics>(*os_p);
872  admin_p->attach(stat);
873  statisticsDestControls.push_back(stat);
874  bool reset = getAparameter<bool>(stat_pset, "reset", false);
875  statisticsResets.push_back(reset);
876 
877  // now configure this destination:
878  configure_dest(stat, psetname);
879 
880  // and suppress the desire to do an extra termination summary just because
881  // of end-of-job info messages
882  stat->noTerminationSummary();
883  }
884 
885  } // for [it = statistics.begin() to end()]
886 
887  } // configure_statistics
uint16_t size_type
std::vector< String > ordinary_destination_filenames
std::map< String, edm::propagate_const< std::ostream * > > stream_ps
edm::propagate_const< std::shared_ptr< ELadministrator > > admin_p
void configure_dest(std::shared_ptr< ELdestination > dest_ctrl, String const &filename)
std::vector< std::shared_ptr< ELstatistics > > statisticsDestControls
std::vector< edm::propagate_const< std::shared_ptr< std::ofstream > > > file_ps
edm::propagate_const< std::shared_ptr< PSet > > job_pset_p
bool search_all(ForwardSequence const &s, Datum const &d)
Definition: Algorithms.h:36
void reset(double vett[256])
Definition: TPedValues.cc:11
value_ptr< MessageLoggerDefaults > messageLoggerDefaults
template<class T >
T edm::service::MessageLoggerScribe::getAparameter ( PSet const &  p,
std::string const &  id,
T const &  def 
)
inlineprivate

Definition at line 149 of file MessageLoggerScribe.h.

References MessageLogger_cfi::cerr, def, MillePedeFileConverter_cfg::e, triggerObjects_cff::id, parseCategories(), cms::Exception::raise(), alignCSCRings::s, AlCaHLTBitMon_QueryRunRegistry::string, and protons_cff::t.

149  {
150  T t = def;
151  try {
152  t = p.template getUntrackedParameter<T>(id, def);
153  } catch (...) {
154  try {
155  t = p.template getParameter<T>(id);
156  } catch (...) {
157  // Since PSetValidation will catch such errors, we simply proceed as
158  // best we can in case we are setting up the logger just to contain the
159  // validation-caught error messages.
160  }
161  }
162  return t;
163  }
long double T
JetCorrectorParameters::Definitions def
Definition: classes.h:6
void edm::service::MessageLoggerScribe::log ( ErrorObj errorobj_p)
private

Definition at line 383 of file MessageLoggerScribe.cc.

References admin_p, myMessageLogger_cff::categories, edm::ELextendedID::id, parseCategories(), edm::ErrorObj::setID(), and edm::ErrorObj::xid().

Referenced by configure_errorlog(), and runCommand().

383  {
384  std::vector<std::string> categories;
385  parseCategories(errorobj_p->xid().id, categories);
386  for (unsigned int icat = 0; icat < categories.size(); ++icat) {
387  errorobj_p->setID(categories[icat]);
388  admin_p->log(*errorobj_p); // route the message text
389  }
390  }
edm::propagate_const< std::shared_ptr< ELadministrator > > admin_p
void parseCategories(std::string const &s, std::vector< std::string > &cats)
void edm::service::MessageLoggerScribe::parseCategories ( std::string const &  s,
std::vector< std::string > &  cats 
)
private

Definition at line 889 of file MessageLoggerScribe.cc.

References mps_fire::i.

Referenced by getAparameter(), and log().

889  {
890  const std::string::size_type npos = std::string::npos;
892  while (i != npos) {
893  std::string::size_type j = s.find('|', i);
894  cats.push_back(s.substr(i, j - i));
895  i = j;
896  while ((i != npos) && (s[i] == '|'))
897  ++i;
898  // the above handles cases of || and also | at end of string
899  }
900  // Note: This algorithm assigns, as desired, one null category if it
901  // encounters an empty categories string
902  }
uint16_t size_type
void edm::service::MessageLoggerScribe::run ( )
virtual

Definition at line 232 of file MessageLoggerScribe.cc.

References done, edm::MessageDrop::instance(), m_queue, edm::MessageDrop::messageLoggerScribeIsRunning, edm::MLSCRIBE_RUNNING_INDICATOR, and runCommand().

Referenced by Types.EventID::cppID(), and Types.LuminosityBlockID::cppID().

232  {
233  MessageLoggerQ::OpCode opcode;
234  void* operand;
235 
237  // std::cerr << "MessageLoggerScribe::run(): \n";
238  // std::cerr << "messageLoggerScribeIsRunning = "
239  // << (int)MessageDrop::instance()->messageLoggerScribeIsRunning << "\n";
240 
241  do {
242  m_queue->consume(opcode, operand); // grab next work item from Q
243  // changeLog 36
244  runCommand(opcode, operand);
245  } while (!done);
246 
247  } // MessageLoggerScribe::run()
static unsigned char messageLoggerScribeIsRunning
Definition: MessageDrop.h:108
static MessageDrop * instance()
Definition: MessageDrop.cc:59
static const unsigned char MLSCRIBE_RUNNING_INDICATOR
Definition: MessageDrop.h:119
void runCommand(MessageLoggerQ::OpCode opcode, void *operand) override
edm::propagate_const< std::shared_ptr< ThreadQueue > > m_queue
void edm::service::MessageLoggerScribe::runCommand ( MessageLoggerQ::OpCode  opcode,
void *  operand 
)
overridevirtual

Reimplemented from edm::service::AbstractMLscribe.

Definition at line 249 of file MessageLoggerScribe.cc.

References active, edm::ConfigurationHandshake::c, MessageLogger_cfi::cerr, edm::MessageLoggerQ::CONFIGURE, configure_errorlog(), count, done, MillePedeFileConverter_cfg::e, edm::MessageLoggerQ::END_THREAD, edm::ConfigurationHandshake::epp, edm::MessageLoggerQ::FJR_SUMMARY, edm::MessageLoggerQ::FLUSH_LOG_Q, edm::MessageLoggerQ::GROUP_STATS, edm::MessageDrop::instance(), job_pset_p, edm::MessageLoggerQ::JOBMODE, log(), edm::MessageLoggerQ::LOG_A_MESSAGE, edm::ConfigurationHandshake::m, messageLoggerDefaults, edm::MessageDrop::messageLoggerScribeIsRunning, edm::service::MessageLoggerDefaults::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().

251  {
252  switch (opcode) { // interpret the work item
253  default: {
254  assert(false); // can't happen (we certainly hope!)
255  break;
256  }
258  assert(operand == nullptr);
259  done = true;
260  MessageDrop::instance()->messageLoggerScribeIsRunning = (unsigned char)-1; // ChangeLog 30
261  break;
262  }
264  ErrorObj* errorobj_p = static_cast<ErrorObj*>(operand);
265  try {
266  if (active && !purge_mode)
267  log(errorobj_p);
268  } catch (cms::Exception& e) {
269  ++count;
270  std::cerr << "MessageLoggerScribe caught " << count << " cms::Exceptions, text = \n" << e.what() << "\n";
271 
272  if (count > 25) {
273  cerr << "MessageLogger will no longer be processing "
274  << "messages due to errors (entering purge mode).\n";
275  purge_mode = true;
276  }
277  } catch (...) {
278  std::cerr << "MessageLoggerScribe caught an unknown exception and "
279  << "will no longer be processing "
280  << "messages. (entering purge mode)\n";
281  purge_mode = true;
282  }
283  delete errorobj_p; // dispose of the message text
284  break;
285  }
286  case MessageLoggerQ::CONFIGURE: { // changelog 17
287  if (singleThread) {
288  job_pset_p =
289  std::shared_ptr<PSet>(static_cast<PSet*>(operand)); // propagate_const<T> has no reset() function
291  break;
292  } else {
293  ConfigurationHandshake* h_p = static_cast<ConfigurationHandshake*>(operand);
294  job_pset_p =
295  std::shared_ptr<PSet>(static_cast<PSet*>(h_p->p)); // propagate_const<T> has no reset() function
296  std::lock_guard<std::mutex> sl(h_p->m); // get lock
297  try {
299  } catch (edm::Exception& e) {
300  Place_for_passing_exception_ptr epp = h_p->epp;
301  if (!(*epp)) {
302  *epp = std::make_shared<edm::Exception>(e);
303  } else {
305  (*ep) << "\n and another exception: \n" << e.what();
306  }
307  }
308  // Note - since the configuring code has not made a new copy of the
309  // job parameter set, we must not delete job_pset_p (in contrast to
310  // the case for errorobj_p). On the other hand, if we instantiate
311  // a new edm::Exception pointed to by *epp, it is the responsibility
312  // of the MessageLoggerQ to delete it.
313  h_p->c.notify_all(); // Signal to MessageLoggerQ that we are done
314  // finally, release the scoped lock by letting it go out of scope
315  break;
316  }
317  }
319  assert(operand == nullptr);
320  try {
322  } catch (cms::Exception& e) {
323  std::cerr << "MessageLoggerScribe caught exception "
324  << "during summarize:\n"
325  << e.what() << "\n";
326  } catch (...) {
327  std::cerr << "MessageLoggerScribe caught unkonwn exception type "
328  << "during summarize. (Ignored)\n";
329  }
330  break;
331  }
332  case MessageLoggerQ::JOBMODE: { // change log 24
333  std::string* jobMode_p = static_cast<std::string*>(operand);
334  JobMode jm = MessageLoggerDefaults::mode(*jobMode_p);
335  messageLoggerDefaults = value_ptr<MessageLoggerDefaults>(new MessageLoggerDefaults(jm));
336  // Note - since messageLoggerDefaults is a value_ptr,
337  // there is no concern about deleting here.
338  delete jobMode_p; // dispose of the message text
339  // which will have been new-ed
340  // in MessageLogger.cc (service version)
341  break;
342  }
344  assert(operand == nullptr);
345  active = false;
346  break;
347  }
348  case MessageLoggerQ::FLUSH_LOG_Q: { // changelog 26
349  if (singleThread)
350  return;
351  ConfigurationHandshake* h_p = static_cast<ConfigurationHandshake*>(operand);
352  job_pset_p = std::shared_ptr<PSet>(static_cast<PSet*>(h_p->p)); // propagate_const<T> has no reset() function
353  std::lock_guard<std::mutex> sl(h_p->m); // get lock
354  h_p->c.notify_all(); // Signal to MessageLoggerQ that we are done
355  // finally, release the scoped lock by letting it go out of scope
356  break;
357  }
358  case MessageLoggerQ::GROUP_STATS: { // change log 27
359  std::string* cat_p = static_cast<std::string*>(operand);
361  delete cat_p; // dispose of the message text
362  break;
363  }
364  case MessageLoggerQ::FJR_SUMMARY: { // changelog 29
365  if (singleThread) {
366  std::map<std::string, double>* smp = static_cast<std::map<std::string, double>*>(operand);
368  break;
369  } else {
370  ConfigurationHandshake* h_p = static_cast<ConfigurationHandshake*>(operand);
371  std::lock_guard<std::mutex> sl(h_p->m); // get lock
372  std::map<std::string, double>* smp = static_cast<std::map<std::string, double>*>(h_p->p);
374  h_p->c.notify_all(); // Signal to MessageLoggerQ that we are done
375  // finally, release the scoped lock by letting it go out of scope
376  break;
377  }
378  }
379  } // switch
380 
381  } // MessageLoggerScribe::runCommand(opcode, operand)
static unsigned char messageLoggerScribeIsRunning
Definition: MessageDrop.h:108
static MessageDrop * instance()
Definition: MessageDrop.cc:59
char const * what() const override
Definition: Exception.cc:103
static void noteGroupedCategory(std::string const &cat)
edm::propagate_const< std::shared_ptr< PSet > > job_pset_p
static edm::JobMode mode(std::string const &jm)
JobMode
Definition: JobMode.h:15
void triggerFJRmessageSummary(std::map< std::string, double > &sm)
std::shared_ptr< Pointer_to_new_exception_on_heap > Place_for_passing_exception_ptr
value_ptr< MessageLoggerDefaults > messageLoggerDefaults
std::shared_ptr< edm::Exception > Pointer_to_new_exception_on_heap
void edm::service::MessageLoggerScribe::triggerFJRmessageSummary ( std::map< std::string, double > &  sm)
private

Definition at line 913 of file MessageLoggerScribe.cc.

References statisticsDestControls.

Referenced by runCommand().

914  {
915  if (statisticsDestControls.empty()) {
916  sm["NoStatisticsDestinationsConfigured"] = 0.0;
917  } else {
918  statisticsDestControls[0]->summaryForJobReport(sm);
919  }
920  }
std::vector< std::shared_ptr< ELstatistics > > statisticsDestControls
void edm::service::MessageLoggerScribe::triggerStatisticsSummaries ( )
private

Definition at line 904 of file MessageLoggerScribe.cc.

References mps_fire::i, statisticsDestControls, and statisticsResets.

Referenced by runCommand().

904  {
905  assert(statisticsDestControls.size() == statisticsResets.size());
906  for (unsigned int i = 0; i != statisticsDestControls.size(); ++i) {
907  statisticsDestControls[i]->summary(0);
908  if (statisticsResets[i])
909  statisticsDestControls[i]->wipe();
910  }
911  }
std::vector< std::shared_ptr< ELstatistics > > statisticsDestControls

Member Data Documentation

bool edm::service::MessageLoggerScribe::active
private

Definition at line 217 of file MessageLoggerScribe.h.

Referenced by runCommand().

edm::propagate_const<std::shared_ptr<ELadministrator> > edm::service::MessageLoggerScribe::admin_p
private
bool edm::service::MessageLoggerScribe::clean_slate_configuration
private
int edm::service::MessageLoggerScribe::count
private

Definition at line 221 of file MessageLoggerScribe.h.

Referenced by runCommand().

bool edm::service::MessageLoggerScribe::done
private

Definition at line 219 of file MessageLoggerScribe.h.

Referenced by run(), and runCommand().

std::shared_ptr<ELdestination> edm::service::MessageLoggerScribe::early_dest
private

Definition at line 208 of file MessageLoggerScribe.h.

Referenced by configure_errorlog(), and configure_ordinary_destinations().

std::vector<edm::propagate_const<std::shared_ptr<std::ofstream> > > edm::service::MessageLoggerScribe::file_ps
private

Definition at line 209 of file MessageLoggerScribe.h.

Referenced by configure_ordinary_destinations(), and configure_statistics().

edm::propagate_const<std::shared_ptr<PSet> > edm::service::MessageLoggerScribe::job_pset_p
private
edm::propagate_const<std::shared_ptr<ThreadQueue> > edm::service::MessageLoggerScribe::m_queue
private

Definition at line 222 of file MessageLoggerScribe.h.

Referenced by configure_errorlog(), and run().

value_ptr<MessageLoggerDefaults> edm::service::MessageLoggerScribe::messageLoggerDefaults
private
std::vector<String> edm::service::MessageLoggerScribe::ordinary_destination_filenames
private

Definition at line 212 of file MessageLoggerScribe.h.

Referenced by configure_ordinary_destinations(), and configure_statistics().

bool edm::service::MessageLoggerScribe::purge_mode
private

Definition at line 220 of file MessageLoggerScribe.h.

Referenced by runCommand().

bool edm::service::MessageLoggerScribe::singleThread
private

Definition at line 218 of file MessageLoggerScribe.h.

Referenced by configure_errorlog(), and runCommand().

std::vector<std::shared_ptr<ELstatistics> > edm::service::MessageLoggerScribe::statisticsDestControls
private
std::vector<bool> edm::service::MessageLoggerScribe::statisticsResets
private

Definition at line 214 of file MessageLoggerScribe.h.

Referenced by configure_statistics(), and triggerStatisticsSummaries().

std::map<String, edm::propagate_const<std::ostream*> > edm::service::MessageLoggerScribe::stream_ps
private