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 108 of file MessageLoggerScribe.h.

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

Definition at line 106 of file MessageLoggerScribe.h.

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

Definition at line 107 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 213 of file MessageLoggerScribe.cc.

214 : admin_p ( new ELadministrator() )
215 , early_dest( admin_p->attach(std::make_shared<ELoutput>(std::cerr, false)) )
216 , file_ps ( )
217 , job_pset_p( )
219 , active( true )
220 , singleThread (queue.get() == nullptr) // changeLog 36
221 , done (false) // changeLog 32
222 , purge_mode (false) // changeLog 32
223 , count (false) // changeLog 32
224 , m_queue(queue) // changeLog 36
225 {
226 }
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 228 of file MessageLoggerScribe.cc.

References admin_p.

229 {
230  admin_p->finish();
231 }
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 459 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().

462 {
463  static const int NO_VALUE_SET = -45654; // change log 2
464  vString empty_vString;
465  PSet empty_PSet;
466  String empty_String;
467 
468  // Defaults: // change log 3a
469  const std::string COMMON_DEFAULT_THRESHOLD = "INFO";
470  const int COMMON_DEFAULT_LIMIT = NO_VALUE_SET;
471  const int COMMON_DEFAULT_INTERVAL = NO_VALUE_SET; // change log 6
472  const int COMMON_DEFAULT_TIMESPAN = NO_VALUE_SET;
473 
474  char const* severity_array[] = {"WARNING", "INFO", "ERROR", "DEBUG"};
475  vString const severities(severity_array+0, severity_array+4);
476 
477  // grab list of categories
479  = getAparameter<vString>(*job_pset_p, "categories", empty_vString);
480 
481  // grab list of messageIDs -- these are a synonym for categories
482  // Note -- the use of messageIDs is deprecated in favor of categories
483  {
484  vString messageIDs
485  = getAparameter<vString>(*job_pset_p, "messageIDs", empty_vString);
486 
487  // combine the lists, not caring about possible duplicates (for now)
488  copy_all( messageIDs, std::back_inserter(categories) );
489  } // no longer need messageIDs
490 
491  // grab list of hardwired categories (hardcats) -- these are to be added
492  // to the list of categories -- change log 24
493  {
494  std::vector<std::string> hardcats = messageLoggerDefaults->categories;
495  // combine the lists, not caring about possible duplicates (for now)
496  copy_all( hardcats, std::back_inserter(categories) );
497  } // no longer need hardcats
498 
499  // grab default threshold common to all destinations
500  String default_threshold
501  = getAparameter<String>(*job_pset_p, "threshold", empty_String);
502  // change log 3a
503  // change log 24
504 
505  // grab default limit/interval/timespan common to all destinations/categories:
506  PSet default_pset
507  = getAparameter<PSet>(*job_pset_p, "default", empty_PSet);
508  int default_limit
509  = getAparameter<int>(default_pset, "limit", COMMON_DEFAULT_LIMIT);
510  int default_interval
511  = getAparameter<int>(default_pset, "reportEvery", COMMON_DEFAULT_INTERVAL);
512  // change log 6, 10
513  int default_timespan
514  = getAparameter<int>(default_pset, "timespan", COMMON_DEFAULT_TIMESPAN);
515  // change log 2a
516  // change log 3a
517  String default_pset_threshold
518  = getAparameter<String>(default_pset, "threshold", default_threshold);
519  // change log 34
520 
521  // grab all of this destination's parameters:
522  PSet dest_pset = getAparameter<PSet>(*job_pset_p, filename, empty_PSet);
523 
524  // See if this is just a placeholder // change log 9
525  bool is_placeholder
526  = getAparameter<bool>(dest_pset, "placeholder", false);
527  if (is_placeholder) return;
528 
529  // grab this destination's default limit/interval/timespan:
530  PSet dest_default_pset
531  = getAparameter<PSet>(dest_pset, "default", empty_PSet);
532  int dest_default_limit
533  = getAparameter<int>(dest_default_pset, "limit", default_limit);
534  int dest_default_interval
535  = getAparameter<int>(dest_default_pset, "reportEvery", default_interval);
536  // change log 6
537  int dest_default_timespan
538  = getAparameter<int>(dest_default_pset, "timespan", default_timespan);
539  // change log 1a
540  if ( dest_default_limit != NO_VALUE_SET ) {
541  if ( dest_default_limit < 0 ) dest_default_limit = 2000000000;
542  dest_ctrl->setLimit("*", dest_default_limit );
543  } // change log 1b, 2a, 2b
544  if ( dest_default_interval != NO_VALUE_SET ) { // change log 6
545  dest_ctrl->setInterval("*", dest_default_interval );
546  }
547  if ( dest_default_timespan != NO_VALUE_SET ) {
548  if ( dest_default_timespan < 0 ) dest_default_timespan = 2000000000;
549  dest_ctrl->setTimespan("*", dest_default_timespan );
550  } // change log 1b, 2a, 2b
551 
552  // establish this destination's threshold:
553  String dest_threshold
554  = getAparameter<String>(dest_pset, "threshold", default_threshold);
555  if (dest_threshold == empty_String) {
556  dest_threshold = default_threshold;
557  }
558  if (dest_threshold == empty_String) { // change log 34
559  dest_threshold = default_pset_threshold;
560  }
561  if (dest_threshold == empty_String) {
562  dest_threshold = messageLoggerDefaults->threshold(filename);
563  }
564  if (dest_threshold == empty_String) dest_threshold = COMMON_DEFAULT_THRESHOLD;
565  ELseverityLevel threshold_sev(dest_threshold);
566  dest_ctrl->setThreshold(threshold_sev);
567  // change log 37
568  if (threshold_sev <= ELseverityLevel::ELsev_success)
570  if (threshold_sev <= ELseverityLevel::ELsev_info)
572  if (threshold_sev <= ELseverityLevel::ELsev_warning)
574 
575  // establish this destination's limit/interval/timespan for each category:
576  for( vString::const_iterator id_it = categories.begin()
577  ; id_it != categories.end()
578  ; ++id_it
579  )
580  {
581  String msgID = *id_it;
582  PSet default_category_pset
583  = getAparameter<PSet>(default_pset, msgID, empty_PSet); // change log 5
584  PSet category_pset
585  = getAparameter<PSet>(dest_pset, msgID, default_category_pset);
586 
587  int category_default_limit
588  = getAparameter<int>(default_category_pset, "limit", NO_VALUE_SET);
589  int limit
590  = getAparameter<int>(category_pset, "limit", category_default_limit);
591  if (limit == NO_VALUE_SET) limit = dest_default_limit;
592  // change log 7
593  int category_default_interval
594  = getAparameter<int>(default_category_pset, "reportEvery", NO_VALUE_SET);
595  int interval
596  = getAparameter<int>(category_pset, "reportEvery",category_default_interval);
597  if (interval == NO_VALUE_SET) interval = dest_default_interval;
598  // change log 6 and then 7
599  int category_default_timespan
600  = getAparameter<int>(default_category_pset, "timespan", NO_VALUE_SET);
601  int timespan
602  = getAparameter<int>(category_pset, "timespan", category_default_timespan);
603  if (timespan == NO_VALUE_SET) timespan = dest_default_timespan;
604  // change log 7
605 
606  const std::string& category = msgID;
607  if ( limit == NO_VALUE_SET ) { // change log 24
608  limit = messageLoggerDefaults->limit(filename,category);
609  }
610  if ( interval == NO_VALUE_SET ) { // change log 24
611  interval = messageLoggerDefaults->reportEvery(filename,category);
612  }
613  if ( timespan == NO_VALUE_SET ) { // change log 24
614  timespan = messageLoggerDefaults->timespan(filename,category);
615  }
616 
617  if( limit != NO_VALUE_SET ) {
618  if ( limit < 0 ) limit = 2000000000;
619  dest_ctrl->setLimit(msgID, limit);
620  } // change log 2a, 2b
621  if( interval != NO_VALUE_SET ) {
622  dest_ctrl->setInterval(msgID, interval);
623  } // change log 6
624  if( timespan != NO_VALUE_SET ) {
625  if ( timespan < 0 ) timespan = 2000000000;
626  dest_ctrl->setTimespan(msgID, timespan);
627  } // change log 2a, 2b
628 
629  } // for
630 
631  // establish this destination's limit for each severity:
632  for( vString::const_iterator sev_it = severities.begin()
633  ; sev_it != severities.end()
634  ; ++sev_it
635  )
636  {
637  String sevID = *sev_it;
638  ELseverityLevel severity(sevID);
639  PSet default_sev_pset
640  = getAparameter<PSet>(default_pset, sevID, empty_PSet);
641  PSet sev_pset
642  = getAparameter<PSet>(dest_pset, sevID, default_sev_pset);
643  // change log 5
644  int limit = getAparameter<int>(sev_pset, "limit", NO_VALUE_SET);
645  if ( limit == NO_VALUE_SET ) { // change log 24
646  limit = messageLoggerDefaults->sev_limit(filename,sevID);
647  }
648  if( limit != NO_VALUE_SET ) {
649  if (limit < 0) limit = 2000000000; // change log 38
650  dest_ctrl->setLimit(severity, limit );
651  }
652  int interval = getAparameter<int>(sev_pset, "reportEvery", NO_VALUE_SET);
653  if ( interval == NO_VALUE_SET ) { // change log 24
654  interval = messageLoggerDefaults->sev_reportEvery(filename,sevID);
655  }
656  if( interval != NO_VALUE_SET ) dest_ctrl->setInterval(severity, interval);
657  // change log 2
658  int timespan = getAparameter<int>(sev_pset, "timespan", NO_VALUE_SET);
659  if ( timespan == NO_VALUE_SET ) { // change log 24
660  timespan = messageLoggerDefaults->sev_timespan(filename,sevID);
661  }
662  if( timespan != NO_VALUE_SET ) {
663  if (timespan < 0) timespan = 2000000000; // change log 38
664  dest_ctrl->setTimespan(severity, timespan );
665  }
666  } // for
667 
668  // establish this destination's linebreak policy:
669  bool noLineBreaks_default
670  = getAparameter<bool> (default_pset, "noLineBreaks", false);
671  // change log 5
672  bool noLineBreaks
673  = getAparameter<bool> (dest_pset, "noLineBreaks", noLineBreaks_default);
674  if (noLineBreaks) {
675  dest_ctrl->setLineLength(32000);
676  }
677  else {
678  int lenDef = 80;
679  int lineLen_default
680  = getAparameter<int> (default_pset, "lineLength", lenDef);
681  // change log 5
682  int lineLen = getAparameter<int> (dest_pset, "lineLength", lineLen_default);
683  if (lineLen != lenDef) {
684  dest_ctrl->setLineLength(lineLen);
685  }
686  }
687 
688  // if indicated, suppress time stamps in this destination's output
689  bool suppressTime_default
690  = getAparameter<bool> (default_pset, "noTimeStamps", false);
691  bool suppressTime
692  = getAparameter<bool> (dest_pset, "noTimeStamps", suppressTime_default);
693  if (suppressTime) {
694  dest_ctrl->suppressTime();
695  }
696 
697 } // MessageLoggerScribe::configure_dest()
static bool debugAlwaysSuppressed
Definition: MessageDrop.h:112
static bool warningAlwaysSuppressed
Definition: MessageDrop.h:114
edm::propagate_const< std::shared_ptr< PSet > > job_pset_p
Func copy_all(ForwardSequence &s, Func f)
wrappers for copy
Definition: Algorithms.h:24
static bool infoAlwaysSuppressed
Definition: MessageDrop.h:113
value_ptr< MessageLoggerDefaults > messageLoggerDefaults
void edm::service::MessageLoggerScribe::configure_errorlog ( )
private

Definition at line 418 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().

419 {
420  vString empty_vString;
421  String empty_String;
422  PSet empty_PSet;
423 
424  // The following is present to test pre-configuration message handling:
425  String preconfiguration_message
426  = getAparameter<String>
427  (*job_pset_p, "generate_preconfiguration_message", empty_String);
428  if (preconfiguration_message != empty_String) {
429  // To test a preconfiguration message without first going thru the
430  // configuration we are about to do, we issue the message (so it sits
431  // on the queue), then copy the processing that the LOG_A_MESSAGE case
432  // does. We suppress the timestamp to allow for automated unit testing.
433  early_dest->suppressTime();
434  LogError ("preconfiguration") << preconfiguration_message;
435  if (!singleThread) {
436  MessageLoggerQ::OpCode opcode;
437  void * operand;
438  m_queue->consume(opcode, operand); // grab next work item from Q
439  assert (opcode == MessageLoggerQ::LOG_A_MESSAGE);
440  ErrorObj * errorobj_p = static_cast<ErrorObj *>(operand);
441  log (errorobj_p);
442  delete errorobj_p; // dispose of the message text
443  }
444  }
445 
446  if ( !stream_ps.empty() ) {
447  LogWarning ("multiLogConfig")
448  << "The message logger has been configured multiple times";
449  clean_slate_configuration = false; // Change Log 22
450  }
451  configure_ordinary_destinations(); // Change Log 16
452  configure_statistics(); // Change Log 16
453 } // 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 700 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().

701 {
702  vString empty_vString;
703  String empty_String;
704  PSet empty_PSet;
705 
706  // Initialize unversal suppression variables
707  MessageDrop::debugAlwaysSuppressed=true; // change log 37
708  MessageDrop::infoAlwaysSuppressed=true; // change log 37
709  MessageDrop::warningAlwaysSuppressed=true; // change log 37
710 
711  // grab list of destinations:
713  = getAparameter<vString>(*job_pset_p, "destinations", empty_vString);
714 
715  // Use the default list of destinations if and only if the grabbed list is
716  // empty // change log 24
717  if (destinations.empty()) {
718  destinations = messageLoggerDefaults->destinations;
719  }
720 
721  // dial down the early destination if other dest's are supplied:
722  if( ! destinations.empty() )
723  early_dest->setThreshold(ELhighestSeverity);
724 
725  // establish each destination:
726  for( vString::const_iterator it = destinations.begin()
727  ; it != destinations.end()
728  ; ++it
729  )
730  {
731  String filename = *it;
732  String psetname = filename;
733 
734  // check that this destination is not just a placeholder // change log 11
735  PSet dest_pset = getAparameter<PSet>(*job_pset_p, psetname, empty_PSet);
736  bool is_placeholder
737  = getAparameter<bool>(dest_pset, "placeholder", false);
738  if (is_placeholder) continue;
739 
740  // Modify the file name if extension or name is explicitly specified
741  // change log 14
742 
743  // Although for an ordinary destination there is no output attribute
744  // for the cfg (you can use filename instead) we provide output() for
745  // uniformity with the statistics destinations. The "right way" to
746  // work this would have been to provide a filename() method, along with
747  // an extension() method. We recognize the potential name confusion here
748  // (filename(filename))!
749 
750  // Determine the destination file name to use if no explicit filename is
751  // supplied in the cfg.
752  String filename_default
753  = getAparameter<String>(dest_pset, "output", empty_String);
754  if ( filename_default == empty_String ) {
755  filename_default = messageLoggerDefaults->output(psetname); // change log 31
756  if (filename_default == empty_String) {
757  filename_default = filename;
758  }
759  }
760 
761  String explicit_filename
762  = getAparameter<String>(dest_pset, "filename", filename_default);
763  if (explicit_filename != empty_String) filename = explicit_filename;
764  String explicit_extension
765  = getAparameter<String>(dest_pset, "extension", empty_String);
766  if (explicit_extension != empty_String) {
767  if (explicit_extension[0] == '.') {
768  filename += explicit_extension;
769  } else {
770  filename = filename + "." + explicit_extension;
771  }
772  }
773 
774  // Attach a default extension of .log if there is no extension on a file
775  // change log 18 - this had been done in concert with attaching destination
776 
777  std::string actual_filename = filename; // change log 4
778  if ( (filename != "cout") && (filename != "cerr") ) {
779  const std::string::size_type npos = std::string::npos;
780  if ( filename.find('.') == npos ) {
781  actual_filename += ".log";
782  }
783  }
784 
785  // Check that this is not a duplicate name // change log 18
786  if ( stream_ps.find(actual_filename)!=stream_ps.end() ) {
787  if (clean_slate_configuration) { // change log 22
788 // throw edm::Exception ( edm::errors::Configuration )
789  LogError("duplicateDestination") // change log 35
790  <<"Duplicate name for a MessageLogger Destination: "
791  << actual_filename
792  << "\n" << "Only the first configuration instructions are used";
793  continue;
794  } else {
795  LogWarning("duplicateDestination")
796  <<"Duplicate name for a MessageLogger Destination: "
797  << actual_filename
798  << "\n" << "Only original configuration instructions are used";
799  continue;
800  }
801  }
802 
803  ordinary_destination_filenames.push_back(actual_filename);
804 
805  // attach the current destination, keeping a control handle to it:
806  std::shared_ptr<ELdestination> dest_ctrl;
807  if( actual_filename == "cout" ) {
808  dest_ctrl = std::make_shared<ELoutput>(std::cout);
809  admin_p->attach( dest_ctrl );
810  stream_ps["cout"] = &std::cout;
811  }
812  else if( actual_filename == "cerr" ) {
813  early_dest->setThreshold(ELzeroSeverity);
814  dest_ctrl = early_dest;
815  stream_ps["cerr"] = &std::cerr;
816  }
817  else {
818  auto os_sp = std::make_shared<std::ofstream>(actual_filename.c_str());
819  file_ps.push_back(os_sp);
820  dest_ctrl = std::make_shared<ELoutput>(*os_sp);
821  admin_p->attach( dest_ctrl );
822  stream_ps[actual_filename] = os_sp.get();
823  }
824 
825  // now configure this destination:
826  configure_dest(dest_ctrl, psetname);
827 
828  } // for [it = destinations.begin() to end()]
829 
830 } // configure_ordinary_destinations
std::map< String, edm::propagate_const< std::ostream * > > stream_ps
ELslProxy< ELhighestSeverityGen > const ELhighestSeverity
uint16_t size_type
std::vector< String > ordinary_destination_filenames
static bool debugAlwaysSuppressed
Definition: MessageDrop.h:112
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:114
edm::propagate_const< std::shared_ptr< PSet > > job_pset_p
static bool infoAlwaysSuppressed
Definition: MessageDrop.h:113
value_ptr< MessageLoggerDefaults > messageLoggerDefaults
void edm::service::MessageLoggerScribe::configure_statistics ( )
private

Definition at line 834 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().

835 {
836  vString empty_vString;
837  String empty_String;
838  PSet empty_PSet;
839 
840  // grab list of statistics destinations:
842  = getAparameter<vString>(*job_pset_p, "statistics", empty_vString);
843 
844  bool no_statistics_configured = statistics.empty(); // change log 24
845 
846  if ( no_statistics_configured ) {
847  // Read the list of staistics destinations from hardwired defaults,
848  // but only if there is also no list of ordinary destinations.
849  // (If a cfg specifies destinations, and no statistics, assume that
850  // is what the user wants.)
852  = getAparameter<vString>(*job_pset_p, "destinations", empty_vString);
853  if (destinations.empty()) {
854  statistics = messageLoggerDefaults->statistics;
855  no_statistics_configured = statistics.empty();
856  }
857  }
858 
859  // establish each statistics destination:
860  for( vString::const_iterator it = statistics.begin()
861  ; it != statistics.end()
862  ; ++it
863  )
864  {
865  String statname = *it;
866  const String& psetname = statname;
867 
868  // check that this destination is not just a placeholder // change log 20
869  PSet stat_pset = getAparameter<PSet>(*job_pset_p, psetname, empty_PSet);
870  bool is_placeholder
871  = getAparameter<bool>(stat_pset, "placeholder", false);
872  if (is_placeholder) continue;
873 
874  // Determine the destination file name
876  = getAparameter<String>(stat_pset, "output", empty_String);
877  if ( filename == empty_String ) {
878  filename = messageLoggerDefaults->output(psetname); // change log 31
879  if (filename == empty_String) {
880  filename = statname;
881  }
882  }
883 
884  // Modify the file name if extension or name is explicitly specified
885  // change log 14 -- probably suspenders and a belt, because ouput option
886  // is present, but uniformity is nice.
887 
888  String explicit_filename
889  = getAparameter<String>(stat_pset, "filename", filename);
890  if (explicit_filename != empty_String) filename = explicit_filename;
891  String explicit_extension
892  = getAparameter<String>(stat_pset, "extension", empty_String);
893  if (explicit_extension != empty_String) {
894  if (explicit_extension[0] == '.') {
895  filename += explicit_extension;
896  } else {
897  filename = filename + "." + explicit_extension;
898  }
899  }
900 
901  // Attach a default extension of .log if there is no extension on a file
902  // change log 18 - this had been done in concert with attaching destination
903 
904  std::string actual_filename = filename; // change log 4
905  if ( (filename != "cout") && (filename != "cerr") ) { // change log 23
906  const std::string::size_type npos = std::string::npos;
907  if ( filename.find('.') == npos ) {
908  actual_filename += ".log";
909  }
910  }
911 
912  // Check that this is not a duplicate name -
913  // unless it is an ordinary destination (which stats can share)
914  if ( !search_all(ordinary_destination_filenames, actual_filename) ) {
915  if ( stream_ps.find(actual_filename)!=stream_ps.end() ) {
916  if (clean_slate_configuration) { // change log 22
918  <<"Duplicate name for a MessageLogger Statistics Destination: "
919  << actual_filename
920  << "\n";
921  } else {
922  LogWarning("duplicateDestination")
923  <<"Duplicate name for a MessageLogger Statistics Destination: "
924  << actual_filename
925  << "\n" << "Only original configuration instructions are used";
926  continue;
927  }
928  }
929  }
930 
931  // create (if statistics file does not match any destination file name)
932  // or note (if statistics file matches a destination file name) the ostream.
933  // But if no statistics destinations were provided in the config, do not
934  // create a new destination for this hardwired statistics - only act if
935  // it is matches a destination. (shange log 24)
936  bool statistics_destination_is_real = !no_statistics_configured;
937  std::ostream* os_p;
938  if ( stream_ps.find(actual_filename) == stream_ps.end() ) {
939  if ( actual_filename == "cout" ) {
940  os_p = &std::cout;
941  } else if ( actual_filename == "cerr" ) {
942  os_p = &std::cerr;
943  } else {
944  auto os_sp = std::make_shared<std::ofstream>(actual_filename.c_str());
945  file_ps.push_back(os_sp);
946  os_p = os_sp.get();
947  }
948  stream_ps[actual_filename] = os_p;
949  } else {
950  statistics_destination_is_real = true; // change log 24
951  os_p = stream_ps[actual_filename];
952  }
953 
954  if (statistics_destination_is_real) { // change log 24
955  // attach the statistics destination, keeping a control handle to it:
956  auto stat = std::make_shared<ELstatistics>(*os_p);
957  admin_p->attach( stat );
958  statisticsDestControls.push_back(stat);
959  bool reset = getAparameter<bool>(stat_pset, "reset", false);
960  statisticsResets.push_back(reset);
961 
962  // now configure this destination:
963  configure_dest(stat, psetname);
964 
965  // and suppress the desire to do an extra termination summary just because
966  // of end-of-job info messages
967  stat->noTerminationSummary();
968  }
969 
970  } // for [it = statistics.begin() to end()]
971 
972 } // configure_statistics
std::map< String, edm::propagate_const< std::ostream * > > stream_ps
uint16_t size_type
std::vector< String > ordinary_destination_filenames
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:46
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 156 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 lumiQTWidget::t.

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

Definition at line 408 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().

408  {
409  std::vector<std::string> categories;
410  parseCategories(errorobj_p->xid().id, categories);
411  for (unsigned int icat = 0; icat < categories.size(); ++icat) {
412  errorobj_p->setID(categories[icat]);
413  admin_p->log( *errorobj_p ); // route the message text
414  }
415 }
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 975 of file MessageLoggerScribe.cc.

References mps_fire::i.

Referenced by getAparameter(), and log().

977 {
978  const std::string::size_type npos = std::string::npos;
980  while ( i != npos ) {
981  std::string::size_type j = s.find('|',i);
982  cats.push_back (s.substr(i,j-i));
983  i = j;
984  while ( (i != npos) && (s[i] == '|') ) ++i;
985  // the above handles cases of || and also | at end of string
986  }
987  // Note: This algorithm assigns, as desired, one null category if it
988  // encounters an empty categories string
989 }
uint16_t size_type
void edm::service::MessageLoggerScribe::run ( )
virtual

Definition at line 235 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().

236 {
237  MessageLoggerQ::OpCode opcode;
238  void * operand;
239 
241  MLSCRIBE_RUNNING_INDICATOR; // ChangeLog 30
242 // std::cerr << "MessageLoggerScribe::run(): \n";
243 // std::cerr << "messageLoggerScribeIsRunning = "
244 // << (int)MessageDrop::instance()->messageLoggerScribeIsRunning << "\n";
245 
246  do {
247  m_queue->consume(opcode, operand); // grab next work item from Q
248  // changeLog 36
249  runCommand (opcode, operand);
250  } while(! done);
251 
252 } // MessageLoggerScribe::run()
static unsigned char messageLoggerScribeIsRunning
Definition: MessageDrop.h:111
static MessageDrop * instance()
Definition: MessageDrop.cc:60
static const unsigned char MLSCRIBE_RUNNING_INDICATOR
Definition: MessageDrop.h:122
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 255 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().

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

References statisticsDestControls.

Referenced by runCommand(), and triggerStatisticsSummaries().

1003 {
1004  if (statisticsDestControls.empty()) {
1005  sm["NoStatisticsDestinationsConfigured"] = 0.0;
1006  } else {
1007  statisticsDestControls[0]->summaryForJobReport(sm);
1008  }
1009 }
std::vector< std::shared_ptr< ELstatistics > > statisticsDestControls
void edm::service::MessageLoggerScribe::triggerStatisticsSummaries ( )
private

Definition at line 992 of file MessageLoggerScribe.cc.

References mps_fire::i, statisticsDestControls, statisticsResets, and triggerFJRmessageSummary().

Referenced by runCommand().

992  {
993  assert (statisticsDestControls.size() == statisticsResets.size());
994  for (unsigned int i = 0; i != statisticsDestControls.size(); ++i) {
995  statisticsDestControls[i]->summary( 0 );
996  if (statisticsResets[i]) statisticsDestControls[i]->wipe( );
997  }
998 }
std::vector< std::shared_ptr< ELstatistics > > statisticsDestControls

Member Data Documentation

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

Definition at line 231 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 235 of file MessageLoggerScribe.h.

Referenced by runCommand().

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

Definition at line 233 of file MessageLoggerScribe.h.

Referenced by run(), and runCommand().

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

Definition at line 222 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 223 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 236 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 226 of file MessageLoggerScribe.h.

Referenced by configure_ordinary_destinations(), and configure_statistics().

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

Definition at line 234 of file MessageLoggerScribe.h.

Referenced by runCommand().

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

Definition at line 232 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 228 of file MessageLoggerScribe.h.

Referenced by configure_statistics(), and triggerStatisticsSummaries().

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