test
CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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 ()
 
virtual void runCommand (MessageLoggerQ::OpCode opcode, void *operand)
 
virtual ~MessageLoggerScribe ()
 
- 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 (ELdestControl &dest_ctrl, String const &filename)
 
void configure_errorlog ()
 
void configure_external_dests ()
 
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
 
ELdestControl early_dest
 
std::vector< NamedDestination * > extern_dests
 
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< ELdestControlstatisticsDestControls
 
std::vector< bool > statisticsResets
 
std::map< String,
edm::propagate_const
< std::ostream * > > 
stream_ps
 

Detailed Description

Definition at line 85 of file MessageLoggerScribe.h.

Member Typedef Documentation

Definition at line 107 of file MessageLoggerScribe.h.

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

Definition at line 105 of file MessageLoggerScribe.h.

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

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

215 : admin_p ( new ELadministrator() )
216 , early_dest( admin_p->attach(ELoutput(std::cerr, false)) )
217 , file_ps ( )
218 , job_pset_p( )
219 , extern_dests( )
221 , active( true )
222 , singleThread (queue.get() == 0) // changeLog 36
223 , done (false) // changeLog 32
224 , purge_mode (false) // changeLog 32
225 , count (false) // changeLog 32
226 , m_queue(queue) // changeLog 36
227 {
228 }
edm::propagate_const< std::shared_ptr< ELadministrator > > admin_p
std::vector< NamedDestination * > extern_dests
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
edm::service::MessageLoggerScribe::~MessageLoggerScribe ( )
virtual

Definition at line 230 of file MessageLoggerScribe.cc.

References admin_p, assert(), and extern_dests.

231 {
232  admin_p->finish();
233  assert( extern_dests.empty() ); // nothing to do
234 }
assert(m_qm.get())
edm::propagate_const< std::shared_ptr< ELadministrator > > admin_p
std::vector< NamedDestination * > extern_dests

Member Function Documentation

void edm::service::MessageLoggerScribe::configure_dest ( ELdestControl dest_ctrl,
String const &  filename 
)
private

Definition at line 489 of file MessageLoggerScribe.cc.

References myMessageLogger_cff::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(), HLT_25ns10e33_v2_cff::severity, AlCaHLTBitMon_QueryRunRegistry::string, edm::service::ELdestControl::suppressTime(), and edm::MessageDrop::warningAlwaysSuppressed.

Referenced by configure_external_dests(), configure_ordinary_destinations(), and configure_statistics().

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

Definition at line 445 of file MessageLoggerScribe.cc.

References assert(), clean_slate_configuration, configure_external_dests(), 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().

446 {
447  vString empty_vString;
448  String empty_String;
449  PSet empty_PSet;
450 
451  // The following is present to test pre-configuration message handling:
452  String preconfiguration_message
453  = getAparameter<String>
454  (*job_pset_p, "generate_preconfiguration_message", empty_String);
455  if (preconfiguration_message != empty_String) {
456  // To test a preconfiguration message without first going thru the
457  // configuration we are about to do, we issue the message (so it sits
458  // on the queue), then copy the processing that the LOG_A_MESSAGE case
459  // does. We suppress the timestamp to allow for automated unit testing.
461  LogError ("preconfiguration") << preconfiguration_message;
462  if (!singleThread) {
463  MessageLoggerQ::OpCode opcode;
464  void * operand;
465  m_queue->consume(opcode, operand); // grab next work item from Q
467  ErrorObj * errorobj_p = static_cast<ErrorObj *>(operand);
468  log (errorobj_p);
469  delete errorobj_p; // dispose of the message text
470  }
471  }
472 
473  if ( !stream_ps.empty() ) {
474  LogWarning ("multiLogConfig")
475  << "The message logger has been configured multiple times";
476  clean_slate_configuration = false; // Change Log 22
477  }
478  configure_ordinary_destinations(); // Change Log 16
479  configure_statistics(); // Change Log 16
480 
482 
483 } // MessageLoggerScribe::configure_errorlog()
std::map< String, edm::propagate_const< std::ostream * > > stream_ps
assert(m_qm.get())
edm::propagate_const< std::shared_ptr< PSet > > job_pset_p
edm::propagate_const< std::shared_ptr< ThreadQueue > > m_queue
void edm::service::MessageLoggerScribe::configure_external_dests ( )
private

Definition at line 1003 of file MessageLoggerScribe.cc.

References admin_p, configure_dest(), alignCSCRings::dest, extern_dests, and job_pset_p.

Referenced by configure_errorlog(), and runCommand().

1004 {
1005  if( ! job_pset_p )
1006  {
1007 // extern_dests.clear();
1008 // change log 12, removed by change log 13
1009  return;
1010  }
1011 
1012  for( auto& dest : extern_dests)
1013  {
1014  ELdestination * dest_p = dest->dest_p().get();
1015  ELdestControl dest_ctrl = admin_p->attach( *dest_p );
1016 
1017  // configure the newly-attached destination:
1018  configure_dest( dest_ctrl, dest->name() );
1019  delete dest; // dispose of our (copy of the) NamedDestination
1020  }
1021  extern_dests.clear();
1022 
1023 } // MessageLoggerScribe::configure_external_dests
edm::propagate_const< std::shared_ptr< ELadministrator > > admin_p
std::vector< NamedDestination * > extern_dests
void configure_dest(ELdestControl &dest_ctrl, String const &filename)
edm::propagate_const< std::shared_ptr< PSet > > job_pset_p
void edm::service::MessageLoggerScribe::configure_ordinary_destinations ( )
private

Definition at line 730 of file MessageLoggerScribe.cc.

References admin_p, ecal_dqm_sourceclient-live_cfg::cerr, clean_slate_configuration, configure_dest(), gather_cfg::cout, edm::MessageDrop::debugAlwaysSuppressed, myMessageLogger_cff::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().

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

Definition at line 862 of file MessageLoggerScribe.cc.

References admin_p, ecal_dqm_sourceclient-live_cfg::cerr, clean_slate_configuration, edm::errors::Configuration, configure_dest(), gather_cfg::cout, myMessageLogger_cff::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().

863 {
864  vString empty_vString;
865  String empty_String;
866  PSet empty_PSet;
867 
868  // grab list of statistics destinations:
870  = getAparameter<vString>(*job_pset_p, "statistics", empty_vString);
871 
872  bool no_statistics_configured = statistics.empty(); // change log 24
873 
874  if ( no_statistics_configured ) {
875  // Read the list of staistics destinations from hardwired defaults,
876  // but only if there is also no list of ordinary destinations.
877  // (If a cfg specifies destinations, and no statistics, assume that
878  // is what the user wants.)
880  = getAparameter<vString>(*job_pset_p, "destinations", empty_vString);
881  if (destinations.empty()) {
882  statistics = messageLoggerDefaults->statistics;
883  no_statistics_configured = statistics.empty();
884  }
885  }
886 
887  // establish each statistics destination:
888  for( vString::const_iterator it = statistics.begin()
889  ; it != statistics.end()
890  ; ++it
891  )
892  {
893  String statname = *it;
894  String psetname = statname;
895 
896  // check that this destination is not just a placeholder // change log 20
897  PSet stat_pset = getAparameter<PSet>(*job_pset_p, psetname, empty_PSet);
898  bool is_placeholder
899  = getAparameter<bool>(stat_pset, "placeholder", false);
900  if (is_placeholder) continue;
901 
902  // Determine the destination file name
904  = getAparameter<String>(stat_pset, "output", empty_String);
905  if ( filename == empty_String ) {
906  filename = messageLoggerDefaults->output(psetname); // change log 31
907  if (filename == empty_String) {
908  filename = statname;
909  }
910  }
911 
912  // Modify the file name if extension or name is explicitly specified
913  // change log 14 -- probably suspenders and a belt, because ouput option
914  // is present, but uniformity is nice.
915 
916  String explicit_filename
917  = getAparameter<String>(stat_pset, "filename", filename);
918  if (explicit_filename != empty_String) filename = explicit_filename;
919  String explicit_extension
920  = getAparameter<String>(stat_pset, "extension", empty_String);
921  if (explicit_extension != empty_String) {
922  if (explicit_extension[0] == '.') {
923  filename += explicit_extension;
924  } else {
925  filename = filename + "." + explicit_extension;
926  }
927  }
928 
929  // Attach a default extension of .log if there is no extension on a file
930  // change log 18 - this had been done in concert with attaching destination
931 
932  std::string actual_filename = filename; // change log 4
933  if ( (filename != "cout") && (filename != "cerr") ) { // change log 23
934  const std::string::size_type npos = std::string::npos;
935  if ( filename.find('.') == npos ) {
936  actual_filename += ".log";
937  }
938  }
939 
940  // Check that this is not a duplicate name -
941  // unless it is an ordinary destination (which stats can share)
942  if ( !search_all(ordinary_destination_filenames, actual_filename) ) {
943  if ( stream_ps.find(actual_filename)!=stream_ps.end() ) {
944  if (clean_slate_configuration) { // change log 22
946  <<"Duplicate name for a MessageLogger Statistics Destination: "
947  << actual_filename
948  << "\n";
949  } else {
950  LogWarning("duplicateDestination")
951  <<"Duplicate name for a MessageLogger Statistics Destination: "
952  << actual_filename
953  << "\n" << "Only original configuration instructions are used";
954  continue;
955  }
956  }
957  }
958 
959  // create (if statistics file does not match any destination file name)
960  // or note (if statistics file matches a destination file name) the ostream.
961  // But if no statistics destinations were provided in the config, do not
962  // create a new destination for this hardwired statistics - only act if
963  // it is matches a destination. (shange log 24)
964  bool statistics_destination_is_real = !no_statistics_configured;
965  std::ostream* os_p;
966  if ( stream_ps.find(actual_filename) == stream_ps.end() ) {
967  if ( actual_filename == "cout" ) {
968  os_p = &std::cout;
969  } else if ( actual_filename == "cerr" ) {
970  os_p = &std::cerr;
971  } else {
972  auto os_sp = std::make_shared<std::ofstream>(actual_filename.c_str());
973  file_ps.push_back(os_sp);
974  os_p = os_sp.get();
975  }
976  stream_ps[actual_filename] = os_p;
977  } else {
978  statistics_destination_is_real = true; // change log 24
979  os_p = stream_ps[actual_filename];
980  }
981 
982  if (statistics_destination_is_real) { // change log 24
983  // attach the statistics destination, keeping a control handle to it:
984  ELdestControl dest_ctrl;
985  dest_ctrl = admin_p->attach( ELstatistics(*os_p) );
986  statisticsDestControls.push_back(dest_ctrl);
987  bool reset = getAparameter<bool>(stat_pset, "reset", false);
988  statisticsResets.push_back(reset);
989 
990  // now configure this destination:
991  configure_dest(dest_ctrl, psetname);
992 
993  // and suppress the desire to do an extra termination summary just because
994  // of end-of-job info messages
995  dest_ctrl.noTerminationSummary();
996  }
997 
998  } // for [it = statistics.begin() to end()]
999 
1000 } // 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
std::vector< edm::propagate_const< std::shared_ptr< std::ofstream > > > file_ps
void configure_dest(ELdestControl &dest_ctrl, String const &filename)
edm::propagate_const< std::shared_ptr< PSet > > job_pset_p
std::vector< ELdestControl > statisticsDestControls
bool search_all(ForwardSequence const &s, Datum const &d)
Definition: Algorithms.h:46
tuple filename
Definition: lut2db_cfg.py:20
tuple cout
Definition: gather_cfg.py:145
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 def, 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 435 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().

435  {
436  std::vector<std::string> categories;
437  parseCategories(errorobj_p->xid().id, categories);
438  for (unsigned int icat = 0; icat < categories.size(); ++icat) {
439  errorobj_p->setID(categories[icat]);
440  admin_p->log( *errorobj_p ); // route the message text
441  }
442 }
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 1026 of file MessageLoggerScribe.cc.

References i, and j.

Referenced by log().

1028 {
1029  const std::string::size_type npos = std::string::npos;
1031  while ( i != npos ) {
1032  std::string::size_type j = s.find('|',i);
1033  cats.push_back (s.substr(i,j-i));
1034  i = j;
1035  while ( (i != npos) && (s[i] == '|') ) ++i;
1036  // the above handles cases of || and also | at end of string
1037  }
1038  // Note: This algorithm assigns, as desired, one null category if it
1039  // encounters an empty categories string
1040 }
int i
Definition: DBlmapReader.cc:9
uint16_t size_type
int j
Definition: DBlmapReader.cc:9
void edm::service::MessageLoggerScribe::run ( void  )
virtual

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

239 {
240  MessageLoggerQ::OpCode opcode;
241  void * operand;
242 
244  MLSCRIBE_RUNNING_INDICATOR; // ChangeLog 30
245 // std::cerr << "MessageLoggerScribe::run(): \n";
246 // std::cerr << "messageLoggerScribeIsRunning = "
247 // << (int)MessageDrop::instance()->messageLoggerScribeIsRunning << "\n";
248 
249  do {
250  m_queue->consume(opcode, operand); // grab next work item from Q
251  // changeLog 36
252  runCommand (opcode, operand);
253  } while(! done);
254 
255 } // MessageLoggerScribe::run()
static unsigned char messageLoggerScribeIsRunning
Definition: MessageDrop.h:111
virtual void runCommand(MessageLoggerQ::OpCode opcode, void *operand)
static MessageDrop * instance()
Definition: MessageDrop.cc:60
static const unsigned char MLSCRIBE_RUNNING_INDICATOR
Definition: MessageDrop.h:122
edm::propagate_const< std::shared_ptr< ThreadQueue > > m_queue
void edm::service::MessageLoggerScribe::runCommand ( MessageLoggerQ::OpCode  opcode,
void *  operand 
)
virtual

Reimplemented from edm::service::AbstractMLscribe.

Definition at line 258 of file MessageLoggerScribe.cc.

References active, assert(), edm::ConfigurationHandshake::c, ecal_dqm_sourceclient-live_cfg::cerr, hitfit::char, edm::MessageLoggerQ::CONFIGURE, configure_errorlog(), configure_external_dests(), count, done, alignCSCRings::e, edm::MessageLoggerQ::END_THREAD, edm::ConfigurationHandshake::epp, edm::MessageLoggerQ::EXTERN_DEST, extern_dests, 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().

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

References statisticsDestControls.

Referenced by runCommand().

1054 {
1055  if (statisticsDestControls.empty()) {
1056  sm["NoStatisticsDestinationsConfigured"] = 0.0;
1057  } else {
1058  statisticsDestControls[0].summaryForJobReport(sm);
1059  }
1060 }
std::vector< ELdestControl > statisticsDestControls
void edm::service::MessageLoggerScribe::triggerStatisticsSummaries ( )
private

Definition at line 1043 of file MessageLoggerScribe.cc.

References assert(), i, statisticsDestControls, and statisticsResets.

Referenced by runCommand().

1043  {
1044  assert (statisticsDestControls.size() == statisticsResets.size());
1045  for (unsigned int i = 0; i != statisticsDestControls.size(); ++i) {
1046  statisticsDestControls[i].summary( );
1047  if (statisticsResets[i]) statisticsDestControls[i].wipe( );
1048  }
1049 }
int i
Definition: DBlmapReader.cc:9
assert(m_qm.get())
std::vector< ELdestControl > statisticsDestControls

Member Data Documentation

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

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

Referenced by runCommand().

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

Definition at line 234 of file MessageLoggerScribe.h.

Referenced by run(), and runCommand().

ELdestControl edm::service::MessageLoggerScribe::early_dest
private

Definition at line 222 of file MessageLoggerScribe.h.

Referenced by configure_errorlog(), and configure_ordinary_destinations().

std::vector<NamedDestination *> edm::service::MessageLoggerScribe::extern_dests
private
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 237 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 227 of file MessageLoggerScribe.h.

Referenced by configure_ordinary_destinations(), and configure_statistics().

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

Definition at line 235 of file MessageLoggerScribe.h.

Referenced by runCommand().

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

Definition at line 233 of file MessageLoggerScribe.h.

Referenced by configure_errorlog(), and runCommand().

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

Definition at line 229 of file MessageLoggerScribe.h.

Referenced by configure_statistics(), and triggerStatisticsSummaries().

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