44 , clean_slate_configuration(
true )
48 , m_messageBeingSent(
false)
49 , m_waitingThreshold(100)
50 , m_tooManyWaitingMessagesCount(0)
63 for (
unsigned int icat = 0; icat < categories.size(); ++icat) {
64 errorobj_p->
setID(categories[icat]);
98 <<
" cms::Exceptions, text = \n" 103 cerr <<
"MessageLogger will no longer be processing " 104 <<
"messages due to errors (entering purge mode).\n";
110 std::cerr <<
"ThreadSafeLogMessageLoggerScribe caught an unknown exception and " 111 <<
"will no longer be processing " 112 <<
"messages. (entering purge mode)\n";
123 assert( operand == 0 );
129 std::cerr <<
"ThreadSafeLogMessageLoggerScribe caught exception " 130 <<
"during summarize:\n" 135 std::cerr <<
"ThreadSafeLogMessageLoggerScribe caught unkonwn exception type " 136 <<
"during summarize. (Ignored)\n";
154 assert( operand == 0 );
169 std::map<std::string, double> * smp =
170 static_cast<std::map<std::string, double> *
>(operand);
179 bool expected =
false;
180 std::unique_ptr<ErrorObj>
obj(errorobj_p);
184 for (
unsigned int icat = 0; icat < categories.size(); ++icat) {
185 errorobj_p->
setID(categories[icat]);
191 obj.reset(errorobj_p);
194 for (
unsigned int icat = 0; icat < categories.size(); ++icat) {
195 errorobj_p->
setID(categories[icat]);
218 String preconfiguration_message
219 = getAparameter<String>
220 (*
job_pset_p,
"generate_preconfiguration_message", empty_String);
221 if (preconfiguration_message != empty_String) {
227 LogError (
"preconfiguration") << preconfiguration_message;
232 <<
"The message logger has been configured multiple times";
250 static const int NO_VALUE_SET = -45654;
256 const std::string COMMON_DEFAULT_THRESHOLD =
"INFO";
257 const int COMMON_DEFAULT_LIMIT = NO_VALUE_SET;
258 const int COMMON_DEFAULT_INTERVAL = NO_VALUE_SET;
259 const int COMMON_DEFAULT_TIMESPAN = NO_VALUE_SET;
261 char const* severity_array[] = {
"WARNING",
"INFO",
"ERROR",
"DEBUG"};
262 vString const severities(severity_array+0, severity_array+4);
266 = getAparameter<vString>(*
job_pset_p,
"categories", empty_vString);
272 = getAparameter<vString>(*
job_pset_p,
"messageIDs", empty_vString);
275 copy_all( messageIDs, std::back_inserter(categories) );
283 copy_all( hardcats, std::back_inserter(categories) );
288 = getAparameter<String>(*
job_pset_p,
"threshold", empty_String);
294 = getAparameter<PSet>(*
job_pset_p,
"default", empty_PSet);
296 = getAparameter<int>(default_pset,
"limit", COMMON_DEFAULT_LIMIT);
298 = getAparameter<int>(default_pset,
"reportEvery", COMMON_DEFAULT_INTERVAL);
301 = getAparameter<int>(default_pset,
"timespan", COMMON_DEFAULT_TIMESPAN);
304 String default_pset_threshold
305 = getAparameter<String>(default_pset,
"threshold", default_threshold);
313 = getAparameter<bool>(dest_pset,
"placeholder",
false);
314 if (is_placeholder)
return;
317 PSet dest_default_pset
318 = getAparameter<PSet>(dest_pset,
"default", empty_PSet);
319 int dest_default_limit
320 = getAparameter<int>(dest_default_pset,
"limit", default_limit);
321 int dest_default_interval
322 = getAparameter<int>(dest_default_pset,
"reportEvery", default_interval);
324 int dest_default_timespan
325 = getAparameter<int>(dest_default_pset,
"timespan", default_timespan);
327 if ( dest_default_limit != NO_VALUE_SET ) {
328 if ( dest_default_limit < 0 ) dest_default_limit = 2000000000;
329 dest_ctrl->setLimit(
"*", dest_default_limit );
331 if ( dest_default_interval != NO_VALUE_SET ) {
332 dest_ctrl->setInterval(
"*", dest_default_interval );
334 if ( dest_default_timespan != NO_VALUE_SET ) {
335 if ( dest_default_timespan < 0 ) dest_default_timespan = 2000000000;
336 dest_ctrl->setTimespan(
"*", dest_default_timespan );
341 = getAparameter<String>(dest_pset,
"threshold", default_threshold);
342 if (dest_threshold == empty_String) {
343 dest_threshold = default_threshold;
345 if (dest_threshold == empty_String) {
346 dest_threshold = default_pset_threshold;
348 if (dest_threshold == empty_String) {
351 if (dest_threshold == empty_String) dest_threshold = COMMON_DEFAULT_THRESHOLD;
353 dest_ctrl->setThreshold(threshold_sev);
363 for( vString::const_iterator id_it = categories.begin()
364 ; id_it != categories.end()
369 PSet default_category_pset
370 = getAparameter<PSet>(default_pset, msgID, empty_PSet);
372 = getAparameter<PSet>(dest_pset, msgID, default_category_pset);
374 int category_default_limit
375 = getAparameter<int>(default_category_pset,
"limit", NO_VALUE_SET);
377 = getAparameter<int>(category_pset,
"limit", category_default_limit);
378 if (limit == NO_VALUE_SET) limit = dest_default_limit;
380 int category_default_interval
381 = getAparameter<int>(default_category_pset,
"reportEvery", NO_VALUE_SET);
383 = getAparameter<int>(category_pset,
"reportEvery",category_default_interval);
384 if (interval == NO_VALUE_SET) interval = dest_default_interval;
386 int category_default_timespan
387 = getAparameter<int>(default_category_pset,
"timespan", NO_VALUE_SET);
389 = getAparameter<int>(category_pset,
"timespan", category_default_timespan);
390 if (timespan == NO_VALUE_SET) timespan = dest_default_timespan;
394 if ( limit == NO_VALUE_SET ) {
397 if ( interval == NO_VALUE_SET ) {
400 if ( timespan == NO_VALUE_SET ) {
404 if( limit != NO_VALUE_SET ) {
405 if ( limit < 0 ) limit = 2000000000;
406 dest_ctrl->setLimit(msgID, limit);
408 if( interval != NO_VALUE_SET ) {
409 dest_ctrl->setInterval(msgID, interval);
411 if( timespan != NO_VALUE_SET ) {
412 if ( timespan < 0 ) timespan = 2000000000;
413 dest_ctrl->setTimespan(msgID, timespan);
419 for( vString::const_iterator sev_it = severities.begin()
420 ; sev_it != severities.end()
426 PSet default_sev_pset
427 = getAparameter<PSet>(default_pset, sevID, empty_PSet);
429 = getAparameter<PSet>(dest_pset, sevID, default_sev_pset);
431 int limit = getAparameter<int>(sev_pset,
"limit", NO_VALUE_SET);
432 if ( limit == NO_VALUE_SET ) {
435 if( limit != NO_VALUE_SET ) {
436 if (limit < 0) limit = 2000000000;
437 dest_ctrl->setLimit(severity, limit );
439 int interval = getAparameter<int>(sev_pset,
"reportEvery", NO_VALUE_SET);
440 if ( interval == NO_VALUE_SET ) {
443 if( interval != NO_VALUE_SET ) dest_ctrl->setInterval(severity, interval);
445 int timespan = getAparameter<int>(sev_pset,
"timespan", NO_VALUE_SET);
446 if ( timespan == NO_VALUE_SET ) {
449 if( timespan != NO_VALUE_SET ) {
450 if (timespan < 0) timespan = 2000000000;
451 dest_ctrl->setTimespan(severity, timespan );
456 bool noLineBreaks_default
457 = getAparameter<bool> (default_pset,
"noLineBreaks",
false);
460 = getAparameter<bool> (dest_pset,
"noLineBreaks", noLineBreaks_default);
462 dest_ctrl->setLineLength(32000);
467 = getAparameter<int> (default_pset,
"lineLength", lenDef);
469 int lineLen = getAparameter<int> (dest_pset,
"lineLength", lineLen_default);
470 if (lineLen != lenDef) {
471 dest_ctrl->setLineLength(lineLen);
476 bool suppressTime_default
477 = getAparameter<bool> (default_pset,
"noTimeStamps",
false);
479 = getAparameter<bool> (dest_pset,
"noTimeStamps", suppressTime_default);
481 dest_ctrl->suppressTime();
500 = getAparameter<vString>(*
job_pset_p,
"destinations", empty_vString);
504 if (destinations.empty()) {
509 if( ! destinations.empty() )
513 for( vString::const_iterator it = destinations.begin()
514 ; it != destinations.end()
522 PSet dest_pset = getAparameter<PSet>(*
job_pset_p, psetname, empty_PSet);
524 = getAparameter<bool>(dest_pset,
"placeholder",
false);
525 if (is_placeholder)
continue;
540 = getAparameter<String>(dest_pset,
"output", empty_String);
541 if ( filename_default == empty_String ) {
543 if (filename_default == empty_String) {
549 = getAparameter<String>(dest_pset,
"filename", filename_default);
550 if (explicit_filename != empty_String) filename = explicit_filename;
552 = getAparameter<String>(dest_pset,
"extension", empty_String);
553 if (explicit_extension != empty_String) {
554 if (explicit_extension[0] ==
'.') {
555 filename += explicit_extension;
557 filename = filename +
"." + explicit_extension;
565 if ( (filename !=
"cout") && (filename !=
"cerr") ) {
567 if ( filename.find(
'.') == npos ) {
568 actual_filename +=
".log";
577 <<
"Duplicate name for a MessageLogger Destination: " 579 <<
"\n" <<
"Only the first configuration instructions are used";
583 <<
"Duplicate name for a MessageLogger Destination: " 585 <<
"\n" <<
"Only original configuration instructions are used";
593 std::shared_ptr<ELdestination> dest_ctrl;
594 if( actual_filename ==
"cout" ) {
598 else if( actual_filename ==
"cerr" ) {
604 auto os_sp = std::make_shared<std::ofstream>(actual_filename.c_str());
606 dest_ctrl =
admin_p->attach( std::make_shared<ELoutput>(*os_sp) );
607 stream_ps[actual_filename] = os_sp.get();
627 = getAparameter<vString>(*
job_pset_p,
"statistics", empty_vString);
629 bool no_statistics_configured = statistics.empty();
631 if ( no_statistics_configured ) {
637 = getAparameter<vString>(*
job_pset_p,
"destinations", empty_vString);
638 if (destinations.empty()) {
640 no_statistics_configured = statistics.empty();
645 for( vString::const_iterator it = statistics.begin()
646 ; it != statistics.end()
651 String psetname = statname;
654 PSet stat_pset = getAparameter<PSet>(*
job_pset_p, psetname, empty_PSet);
656 = getAparameter<bool>(stat_pset,
"placeholder",
false);
657 if (is_placeholder)
continue;
661 = getAparameter<String>(stat_pset,
"output", empty_String);
662 if ( filename == empty_String ) {
664 if (filename == empty_String) {
674 = getAparameter<String>(stat_pset,
"filename",
filename);
675 if (explicit_filename != empty_String) filename = explicit_filename;
677 = getAparameter<String>(stat_pset,
"extension", empty_String);
678 if (explicit_extension != empty_String) {
679 if (explicit_extension[0] ==
'.') {
680 filename += explicit_extension;
682 filename = filename +
"." + explicit_extension;
690 if ( (filename !=
"cout") && (filename !=
"cerr") ) {
692 if ( filename.find(
'.') == npos ) {
693 actual_filename +=
".log";
703 <<
"Duplicate name for a MessageLogger Statistics Destination: " 708 <<
"Duplicate name for a MessageLogger Statistics Destination: " 710 <<
"\n" <<
"Only original configuration instructions are used";
721 bool statistics_destination_is_real = !no_statistics_configured;
724 if ( actual_filename ==
"cout" ) {
726 }
else if ( actual_filename ==
"cerr" ) {
729 auto os_sp = std::make_shared<std::ofstream>(actual_filename.c_str());
735 statistics_destination_is_real =
true;
739 if (statistics_destination_is_real) {
741 auto stat = std::make_shared<ELstatistics>(*os_p);
744 bool reset = getAparameter<bool>(stat_pset,
"reset",
false);
752 stat->noTerminationSummary();
761 std::vector<std::string> & cats)
765 while ( i != npos ) {
767 cats.push_back (s.substr(i,j-i));
769 while ( (i != npos) && (s[
i] ==
'|') ) ++
i;
790 sm[
"NoStatisticsDestinationsConfigured"] = 0.0;
std::vector< std::shared_ptr< ELstatistics > > statisticsDestControls
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
char const * what() const override
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
size_t m_waitingThreshold
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
edm::propagate_const< std::shared_ptr< PSet > > job_pset_p
std::vector< String > vString
static void noteGroupedCategory(std::string const &cat)
std::atomic< unsigned long > m_tooManyWaitingMessagesCount
static bool warningAlwaysSuppressed
virtual void setID(const ELstring &ID)
std::shared_ptr< ELdestination > early_dest
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()
Func copy_all(ForwardSequence &s, Func f)
wrappers for copy
void configure_dest(std::shared_ptr< ELdestination > dest_ctrl, String const &filename)
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()