46 , clean_slate_configuration(
true )
50 , m_messageBeingSent(
false)
63 for (
unsigned int icat = 0; icat < categories.size(); ++icat) {
64 errorobj_p->
setID(categories[icat]);
99 <<
" cms::Exceptions, text = \n" 104 cerr <<
"MessageLogger will no longer be processing " 105 <<
"messages due to errors (entering purge mode).\n";
111 std::cerr <<
"ThreadSafeLogMessageLoggerScribe caught an unknown exception and " 112 <<
"will no longer be processing " 113 <<
"messages. (entering purge mode)\n";
125 extern_dests.push_back( static_cast<NamedDestination *>(operand) );
130 std::cerr <<
"ThreadSafeLogMessageLoggerScribe caught a cms::Exception " 131 <<
"during extern dest configuration:\n" 133 <<
"This is a serious problem, and the extern dest " 134 <<
"will not be produced.\n" 135 <<
"However, the rest of the logger continues to run.\n";
139 std::cerr <<
"ThreadSafeLogMessageLoggerScribe caught unkonwn exception type\n" 140 <<
"during extern dest configuration. " 141 <<
"This is a serious problem, and the extern dest " 142 <<
"will not be produced.\n" 143 <<
"The rest of the logger will attempt to continue to run.\n";
148 assert( operand == 0 );
154 std::cerr <<
"ThreadSafeLogMessageLoggerScribe caught exception " 155 <<
"during summarize:\n" 160 std::cerr <<
"ThreadSafeLogMessageLoggerScribe caught unkonwn exception type " 161 <<
"during summarize. (Ignored)\n";
179 assert( operand == 0 );
194 std::map<std::string, double> * smp =
195 static_cast<std::map<std::string, double> *
>(operand);
204 bool expected =
false;
205 std::unique_ptr<ErrorObj>
obj(errorobj_p);
209 for (
unsigned int icat = 0; icat < categories.size(); ++icat) {
210 errorobj_p->
setID(categories[icat]);
216 obj.reset(errorobj_p);
219 for (
unsigned int icat = 0; icat < categories.size(); ++icat) {
220 errorobj_p->
setID(categories[icat]);
239 String preconfiguration_message
240 = getAparameter<String>
241 (*
job_pset_p,
"generate_preconfiguration_message", empty_String);
242 if (preconfiguration_message != empty_String) {
248 LogError (
"preconfiguration") << preconfiguration_message;
253 <<
"The message logger has been configured multiple times";
271 static const int NO_VALUE_SET = -45654;
277 const std::string COMMON_DEFAULT_THRESHOLD =
"INFO";
278 const int COMMON_DEFAULT_LIMIT = NO_VALUE_SET;
279 const int COMMON_DEFAULT_INTERVAL = NO_VALUE_SET;
280 const int COMMON_DEFAULT_TIMESPAN = NO_VALUE_SET;
282 char const* severity_array[] = {
"WARNING",
"INFO",
"ERROR",
"DEBUG"};
283 vString const severities(severity_array+0, severity_array+4);
287 = getAparameter<vString>(*
job_pset_p,
"categories", empty_vString);
293 = getAparameter<vString>(*
job_pset_p,
"messageIDs", empty_vString);
296 copy_all( messageIDs, std::back_inserter(categories) );
304 copy_all( hardcats, std::back_inserter(categories) );
309 = getAparameter<String>(*
job_pset_p,
"threshold", empty_String);
315 = getAparameter<PSet>(*
job_pset_p,
"default", empty_PSet);
317 = getAparameter<int>(default_pset,
"limit", COMMON_DEFAULT_LIMIT);
319 = getAparameter<int>(default_pset,
"reportEvery", COMMON_DEFAULT_INTERVAL);
322 = getAparameter<int>(default_pset,
"timespan", COMMON_DEFAULT_TIMESPAN);
325 String default_pset_threshold
326 = getAparameter<String>(default_pset,
"threshold", default_threshold);
334 = getAparameter<bool>(dest_pset,
"placeholder",
false);
335 if (is_placeholder)
return;
338 PSet dest_default_pset
339 = getAparameter<PSet>(dest_pset,
"default", empty_PSet);
340 int dest_default_limit
341 = getAparameter<int>(dest_default_pset,
"limit", default_limit);
342 int dest_default_interval
343 = getAparameter<int>(dest_default_pset,
"reportEvery", default_interval);
345 int dest_default_timespan
346 = getAparameter<int>(dest_default_pset,
"timespan", default_timespan);
348 if ( dest_default_limit != NO_VALUE_SET ) {
349 if ( dest_default_limit < 0 ) dest_default_limit = 2000000000;
350 dest_ctrl.
setLimit(
"*", dest_default_limit );
352 if ( dest_default_interval != NO_VALUE_SET ) {
353 dest_ctrl.
setInterval(
"*", dest_default_interval );
355 if ( dest_default_timespan != NO_VALUE_SET ) {
356 if ( dest_default_timespan < 0 ) dest_default_timespan = 2000000000;
357 dest_ctrl.
setTimespan(
"*", dest_default_timespan );
362 = getAparameter<String>(dest_pset,
"threshold", default_threshold);
363 if (dest_threshold == empty_String) {
364 dest_threshold = default_threshold;
366 if (dest_threshold == empty_String) {
367 dest_threshold = default_pset_threshold;
369 if (dest_threshold == empty_String) {
372 if (dest_threshold == empty_String) dest_threshold = COMMON_DEFAULT_THRESHOLD;
384 for( vString::const_iterator id_it = categories.begin()
385 ; id_it != categories.end()
390 PSet default_category_pset
391 = getAparameter<PSet>(default_pset, msgID, empty_PSet);
393 = getAparameter<PSet>(dest_pset, msgID, default_category_pset);
395 int category_default_limit
396 = getAparameter<int>(default_category_pset,
"limit", NO_VALUE_SET);
398 = getAparameter<int>(category_pset,
"limit", category_default_limit);
399 if (limit == NO_VALUE_SET) limit = dest_default_limit;
401 int category_default_interval
402 = getAparameter<int>(default_category_pset,
"reportEvery", NO_VALUE_SET);
404 = getAparameter<int>(category_pset,
"reportEvery",category_default_interval);
405 if (interval == NO_VALUE_SET) interval = dest_default_interval;
407 int category_default_timespan
408 = getAparameter<int>(default_category_pset,
"timespan", NO_VALUE_SET);
410 = getAparameter<int>(category_pset,
"timespan", category_default_timespan);
411 if (timespan == NO_VALUE_SET) timespan = dest_default_timespan;
415 if ( limit == NO_VALUE_SET ) {
418 if ( interval == NO_VALUE_SET ) {
421 if ( timespan == NO_VALUE_SET ) {
425 if( limit != NO_VALUE_SET ) {
426 if ( limit < 0 ) limit = 2000000000;
429 if( interval != NO_VALUE_SET ) {
432 if( timespan != NO_VALUE_SET ) {
433 if ( timespan < 0 ) timespan = 2000000000;
440 for( vString::const_iterator sev_it = severities.begin()
441 ; sev_it != severities.end()
447 PSet default_sev_pset
448 = getAparameter<PSet>(default_pset, sevID, empty_PSet);
450 = getAparameter<PSet>(dest_pset, sevID, default_sev_pset);
452 int limit = getAparameter<int>(sev_pset,
"limit", NO_VALUE_SET);
453 if ( limit == NO_VALUE_SET ) {
456 if( limit != NO_VALUE_SET ) {
457 if (limit < 0) limit = 2000000000;
458 dest_ctrl.
setLimit(severity, limit );
460 int interval = getAparameter<int>(sev_pset,
"reportEvery", NO_VALUE_SET);
461 if ( interval == NO_VALUE_SET ) {
464 if( interval != NO_VALUE_SET ) dest_ctrl.
setInterval(severity, interval);
466 int timespan = getAparameter<int>(sev_pset,
"timespan", NO_VALUE_SET);
467 if ( timespan == NO_VALUE_SET ) {
470 if( timespan != NO_VALUE_SET ) {
471 if (timespan < 0) timespan = 2000000000;
477 bool noLineBreaks_default
478 = getAparameter<bool> (default_pset,
"noLineBreaks",
false);
481 = getAparameter<bool> (dest_pset,
"noLineBreaks", noLineBreaks_default);
488 = getAparameter<int> (default_pset,
"lineLength", lenDef);
490 int lineLen = getAparameter<int> (dest_pset,
"lineLength", lineLen_default);
491 if (lineLen != lenDef) {
497 bool suppressTime_default
498 = getAparameter<bool> (default_pset,
"noTimeStamps",
false);
500 = getAparameter<bool> (dest_pset,
"noTimeStamps", suppressTime_default);
521 = getAparameter<vString>(*
job_pset_p,
"destinations", empty_vString);
525 if (destinations.empty()) {
530 if( ! destinations.empty() )
534 for( vString::const_iterator it = destinations.begin()
535 ; it != destinations.end()
543 PSet dest_pset = getAparameter<PSet>(*
job_pset_p, psetname, empty_PSet);
545 = getAparameter<bool>(dest_pset,
"placeholder",
false);
546 if (is_placeholder)
continue;
561 = getAparameter<String>(dest_pset,
"output", empty_String);
562 if ( filename_default == empty_String ) {
564 if (filename_default == empty_String) {
570 = getAparameter<String>(dest_pset,
"filename", filename_default);
571 if (explicit_filename != empty_String) filename = explicit_filename;
573 = getAparameter<String>(dest_pset,
"extension", empty_String);
574 if (explicit_extension != empty_String) {
575 if (explicit_extension[0] ==
'.') {
576 filename += explicit_extension;
578 filename = filename +
"." + explicit_extension;
586 if ( (filename !=
"cout") && (filename !=
"cerr") ) {
588 if ( filename.find(
'.') == npos ) {
589 actual_filename +=
".log";
598 <<
"Duplicate name for a MessageLogger Destination: " 600 <<
"\n" <<
"Only the first configuration instructions are used";
604 <<
"Duplicate name for a MessageLogger Destination: " 606 <<
"\n" <<
"Only original configuration instructions are used";
615 if( actual_filename ==
"cout" ) {
619 else if( actual_filename ==
"cerr" ) {
625 auto os_sp = std::make_shared<std::ofstream>(actual_filename.c_str());
628 stream_ps[actual_filename] = os_sp.get();
648 = getAparameter<vString>(*
job_pset_p,
"statistics", empty_vString);
650 bool no_statistics_configured = statistics.empty();
652 if ( no_statistics_configured ) {
658 = getAparameter<vString>(*
job_pset_p,
"destinations", empty_vString);
659 if (destinations.empty()) {
661 no_statistics_configured = statistics.empty();
666 for( vString::const_iterator it = statistics.begin()
667 ; it != statistics.end()
672 String psetname = statname;
675 PSet stat_pset = getAparameter<PSet>(*
job_pset_p, psetname, empty_PSet);
677 = getAparameter<bool>(stat_pset,
"placeholder",
false);
678 if (is_placeholder)
continue;
682 = getAparameter<String>(stat_pset,
"output", empty_String);
683 if ( filename == empty_String ) {
685 if (filename == empty_String) {
695 = getAparameter<String>(stat_pset,
"filename",
filename);
696 if (explicit_filename != empty_String) filename = explicit_filename;
698 = getAparameter<String>(stat_pset,
"extension", empty_String);
699 if (explicit_extension != empty_String) {
700 if (explicit_extension[0] ==
'.') {
701 filename += explicit_extension;
703 filename = filename +
"." + explicit_extension;
711 if ( (filename !=
"cout") && (filename !=
"cerr") ) {
713 if ( filename.find(
'.') == npos ) {
714 actual_filename +=
".log";
724 <<
"Duplicate name for a MessageLogger Statistics Destination: " 729 <<
"Duplicate name for a MessageLogger Statistics Destination: " 731 <<
"\n" <<
"Only original configuration instructions are used";
742 bool statistics_destination_is_real = !no_statistics_configured;
745 if ( actual_filename ==
"cout" ) {
747 }
else if ( actual_filename ==
"cerr" ) {
750 auto os_sp = std::make_shared<std::ofstream>(actual_filename.c_str());
756 statistics_destination_is_real =
true;
760 if (statistics_destination_is_real) {
765 bool reset = getAparameter<bool>(stat_pset,
"reset",
false);
799 extern_dests.clear();
805 std::vector<std::string> & cats)
809 while ( i != npos ) {
811 cats.push_back (s.substr(i,j-i));
813 while ( (i != npos) && (s[
i] ==
'|') ) ++
i;
834 sm[
"NoStatisticsDestinationsConfigured"] = 0.0;
virtual char const * what() const
ELdestControl & setLimit(const ELstring &s, int n)
ELdestControl & setThreshold(const ELseverityLevel &sv)
std::vector< bool > statisticsResets
std::vector< edm::propagate_const< std::shared_ptr< std::ofstream > > > file_ps
virtual void runCommand(MessageLoggerQ::OpCode opcode, void *operand)
void triggerStatisticsSummaries()
std::atomic< bool > purge_mode
void configure_dest(ELdestControl &dest_ctrl, String const &filename)
ELdestControl & setTimespan(const ELstring &s, int n)
ELslProxy< ELhighestSeverityGen > const ELhighestSeverity
void triggerFJRmessageSummary(std::map< std::string, double > &sm)
value_ptr< MessageLoggerDefaults > messageLoggerDefaults
std::vector< String > ordinary_destination_filenames
static bool debugAlwaysSuppressed
tbb::concurrent_queue< ErrorObj * > m_waitingMessages
int setLineLength(int len)
void configure_errorlog()
const ELextendedID & xid() const
ELslProxy< ELzeroSeverityGen > const ELzeroSeverity
ThreadSafeLogMessageLoggerScribe()
— If queue is NULL, this sets singleThread true
std::map< String, edm::propagate_const< std::ostream * > > stream_ps
std::atomic< bool > m_messageBeingSent
std::vector< ELdestControl > statisticsDestControls
std::vector< NamedDestination * > extern_dests
edm::propagate_const< std::shared_ptr< PSet > > job_pset_p
std::vector< String > vString
static void noteGroupedCategory(std::string const &cat)
void noTerminationSummary()
static bool warningAlwaysSuppressed
virtual void setID(const ELstring &ID)
void configure_external_dests()
bool search_all(ForwardSequence const &s, Datum const &d)
static edm::JobMode mode(std::string const &jm)
edm::propagate_const< std::shared_ptr< ELadministrator > > admin_p
virtual ~ThreadSafeLogMessageLoggerScribe()
ELdestControl & setInterval(const ELstring &s, int interval)
Func copy_all(ForwardSequence &s, Func f)
wrappers for copy
void log(ErrorObj *errorobj_p)
void parseCategories(std::string const &s, std::vector< std::string > &cats)
bool clean_slate_configuration
static bool infoAlwaysSuppressed
void reset(double vett[256])
void configure_ordinary_destinations()
void configure_statistics()