43 clean_slate_configuration(
true),
49 m_messageBeingSent(
false),
50 m_waitingThreshold(100),
51 m_tooManyWaitingMessagesCount(0) {}
61 for (
unsigned int icat = 0; icat < categories.size(); ++icat) {
62 errorobj_p->
setID(categories[icat]);
91 std::cerr <<
"ThreadSafeLogMessageLoggerScribe caught " <<
count <<
" cms::Exceptions, text = \n" 95 cerr <<
"MessageLogger will no longer be processing " 96 <<
"messages due to errors (entering purge mode).\n";
100 std::cerr <<
"ThreadSafeLogMessageLoggerScribe caught an unknown exception and " 101 <<
"will no longer be processing " 102 <<
"messages. (entering purge mode)\n";
109 std::shared_ptr<PSet>(
static_cast<PSet*
>(operand));
114 assert(operand ==
nullptr);
118 std::cerr <<
"ThreadSafeLogMessageLoggerScribe caught exception " 119 <<
"during summarize:\n" 122 std::cerr <<
"ThreadSafeLogMessageLoggerScribe caught unkonwn exception type " 123 <<
"during summarize. (Ignored)\n";
139 assert(operand ==
nullptr);
153 std::map<std::string, double>* smp =
static_cast<std::map<std::string, double>*
>(operand);
162 bool expected =
false;
163 std::unique_ptr<ErrorObj>
obj(errorobj_p);
167 for (
unsigned int icat = 0; icat < categories.size(); ++icat) {
168 errorobj_p->
setID(categories[icat]);
172 errorobj_p =
nullptr;
174 obj.reset(errorobj_p);
177 for (
unsigned int icat = 0; icat < categories.size(); ++icat) {
178 errorobj_p->
setID(categories[icat]);
199 String preconfiguration_message =
200 getAparameter<String>(*
job_pset_p,
"generate_preconfiguration_message", empty_String);
201 if (preconfiguration_message != empty_String) {
207 LogError(
"preconfiguration") << preconfiguration_message;
211 LogWarning(
"multiLogConfig") <<
"The message logger has been configured multiple times";
221 static const int NO_VALUE_SET = -45654;
227 const std::string COMMON_DEFAULT_THRESHOLD =
"INFO";
228 const int COMMON_DEFAULT_LIMIT = NO_VALUE_SET;
229 const int COMMON_DEFAULT_INTERVAL = NO_VALUE_SET;
230 const int COMMON_DEFAULT_TIMESPAN = NO_VALUE_SET;
232 char const* severity_array[] = {
"WARNING",
"INFO",
"ERROR",
"DEBUG"};
233 vString const severities(severity_array + 0, severity_array + 4);
241 vString messageIDs = getAparameter<vString>(*
job_pset_p,
"messageIDs", empty_vString);
244 copy_all(messageIDs, std::back_inserter(categories));
252 copy_all(hardcats, std::back_inserter(categories));
256 String default_threshold = getAparameter<String>(*
job_pset_p,
"threshold", empty_String);
261 PSet default_pset = getAparameter<PSet>(*
job_pset_p,
"default", empty_PSet);
262 int default_limit = getAparameter<int>(default_pset,
"limit", COMMON_DEFAULT_LIMIT);
263 int default_interval = getAparameter<int>(default_pset,
"reportEvery", COMMON_DEFAULT_INTERVAL);
265 int default_timespan = getAparameter<int>(default_pset,
"timespan", COMMON_DEFAULT_TIMESPAN);
268 String default_pset_threshold = getAparameter<String>(default_pset,
"threshold", default_threshold);
275 bool is_placeholder = getAparameter<bool>(dest_pset,
"placeholder",
false);
280 PSet dest_default_pset = getAparameter<PSet>(dest_pset,
"default", empty_PSet);
281 int dest_default_limit = getAparameter<int>(dest_default_pset,
"limit", default_limit);
282 int dest_default_interval = getAparameter<int>(dest_default_pset,
"reportEvery", default_interval);
284 int dest_default_timespan = getAparameter<int>(dest_default_pset,
"timespan", default_timespan);
286 if (dest_default_limit != NO_VALUE_SET) {
287 if (dest_default_limit < 0)
288 dest_default_limit = 2000000000;
289 dest_ctrl->setLimit(
"*", dest_default_limit);
291 if (dest_default_interval != NO_VALUE_SET) {
292 dest_ctrl->setInterval(
"*", dest_default_interval);
294 if (dest_default_timespan != NO_VALUE_SET) {
295 if (dest_default_timespan < 0)
296 dest_default_timespan = 2000000000;
297 dest_ctrl->setTimespan(
"*", dest_default_timespan);
301 String dest_threshold = getAparameter<String>(dest_pset,
"threshold", default_threshold);
302 if (dest_threshold == empty_String) {
303 dest_threshold = default_threshold;
305 if (dest_threshold == empty_String) {
306 dest_threshold = default_pset_threshold;
308 if (dest_threshold == empty_String) {
311 if (dest_threshold == empty_String)
312 dest_threshold = COMMON_DEFAULT_THRESHOLD;
314 dest_ctrl->setThreshold(threshold_sev);
327 for (vString::const_iterator id_it = categories.begin(); id_it != categories.end(); ++id_it) {
329 PSet default_category_pset = getAparameter<PSet>(default_pset, msgID, empty_PSet);
330 PSet category_pset = getAparameter<PSet>(dest_pset, msgID, default_category_pset);
332 int category_default_limit = getAparameter<int>(default_category_pset,
"limit", NO_VALUE_SET);
333 int limit = getAparameter<int>(category_pset,
"limit", category_default_limit);
334 if (limit == NO_VALUE_SET)
335 limit = dest_default_limit;
337 int category_default_interval = getAparameter<int>(default_category_pset,
"reportEvery", NO_VALUE_SET);
338 int interval = getAparameter<int>(category_pset,
"reportEvery", category_default_interval);
339 if (interval == NO_VALUE_SET)
340 interval = dest_default_interval;
342 int category_default_timespan = getAparameter<int>(default_category_pset,
"timespan", NO_VALUE_SET);
343 int timespan = getAparameter<int>(category_pset,
"timespan", category_default_timespan);
344 if (timespan == NO_VALUE_SET)
345 timespan = dest_default_timespan;
349 if (limit == NO_VALUE_SET) {
352 if (interval == NO_VALUE_SET) {
355 if (timespan == NO_VALUE_SET) {
359 if (limit != NO_VALUE_SET) {
362 dest_ctrl->setLimit(msgID, limit);
364 if (interval != NO_VALUE_SET) {
365 dest_ctrl->setInterval(msgID, interval);
367 if (timespan != NO_VALUE_SET) {
369 timespan = 2000000000;
370 dest_ctrl->setTimespan(msgID, timespan);
376 for (vString::const_iterator sev_it = severities.begin(); sev_it != severities.end(); ++sev_it) {
379 PSet default_sev_pset = getAparameter<PSet>(default_pset, sevID, empty_PSet);
380 PSet sev_pset = getAparameter<PSet>(dest_pset, sevID, default_sev_pset);
382 int limit = getAparameter<int>(sev_pset,
"limit", NO_VALUE_SET);
383 if (limit == NO_VALUE_SET) {
386 if (limit != NO_VALUE_SET) {
389 dest_ctrl->setLimit(severity, limit);
391 int interval = getAparameter<int>(sev_pset,
"reportEvery", NO_VALUE_SET);
392 if (interval == NO_VALUE_SET) {
395 if (interval != NO_VALUE_SET)
396 dest_ctrl->setInterval(severity, interval);
398 int timespan = getAparameter<int>(sev_pset,
"timespan", NO_VALUE_SET);
399 if (timespan == NO_VALUE_SET) {
402 if (timespan != NO_VALUE_SET) {
404 timespan = 2000000000;
405 dest_ctrl->setTimespan(severity, timespan);
410 bool noLineBreaks_default = getAparameter<bool>(default_pset,
"noLineBreaks",
false);
412 bool noLineBreaks = getAparameter<bool>(dest_pset,
"noLineBreaks", noLineBreaks_default);
414 dest_ctrl->setLineLength(32000);
417 int lineLen_default = getAparameter<int>(default_pset,
"lineLength", lenDef);
419 int lineLen = getAparameter<int>(dest_pset,
"lineLength", lineLen_default);
420 if (lineLen != lenDef) {
421 dest_ctrl->setLineLength(lineLen);
426 bool suppressTime_default = getAparameter<bool>(default_pset,
"noTimeStamps",
false);
427 bool suppressTime = getAparameter<bool>(dest_pset,
"noTimeStamps", suppressTime_default);
429 dest_ctrl->suppressTime();
450 if (destinations.empty()) {
455 if (!destinations.empty())
459 for (vString::const_iterator it = destinations.begin(); it != destinations.end(); ++it) {
464 PSet dest_pset = getAparameter<PSet>(*
job_pset_p, psetname, empty_PSet);
465 bool is_placeholder = getAparameter<bool>(dest_pset,
"placeholder",
false);
481 String filename_default = getAparameter<String>(dest_pset,
"output", empty_String);
482 if (filename_default == empty_String) {
484 if (filename_default == empty_String) {
489 String explicit_filename = getAparameter<String>(dest_pset,
"filename", filename_default);
490 if (explicit_filename != empty_String)
491 filename = explicit_filename;
492 String explicit_extension = getAparameter<String>(dest_pset,
"extension", empty_String);
493 if (explicit_extension != empty_String) {
494 if (explicit_extension[0] ==
'.') {
495 filename += explicit_extension;
497 filename = filename +
"." + explicit_extension;
505 if ((filename !=
"cout") && (filename !=
"cerr")) {
507 if (filename.find(
'.') == npos) {
508 actual_filename +=
".log";
517 <<
"Duplicate name for a MessageLogger Destination: " << actual_filename <<
"\n" 518 <<
"Only the first configuration instructions are used";
522 <<
"Duplicate name for a MessageLogger Destination: " << actual_filename <<
"\n" 523 <<
"Only original configuration instructions are used";
531 std::shared_ptr<ELdestination> dest_ctrl;
532 if (actual_filename ==
"cout") {
535 }
else if (actual_filename ==
"cerr") {
540 auto os_sp = std::make_shared<std::ofstream>(actual_filename.c_str());
542 dest_ctrl =
admin_p->attach(std::make_shared<ELoutput>(*os_sp));
543 stream_ps[actual_filename] = os_sp.get();
561 bool no_statistics_configured = statistics.empty();
563 if (no_statistics_configured) {
569 if (destinations.empty()) {
571 no_statistics_configured = statistics.empty();
576 for (vString::const_iterator it = statistics.begin(); it != statistics.end(); ++it) {
578 const String& psetname = statname;
581 PSet stat_pset = getAparameter<PSet>(*
job_pset_p, psetname, empty_PSet);
582 bool is_placeholder = getAparameter<bool>(stat_pset,
"placeholder",
false);
587 String filename = getAparameter<String>(stat_pset,
"output", empty_String);
588 if (filename == empty_String) {
590 if (filename == empty_String) {
599 String explicit_filename = getAparameter<String>(stat_pset,
"filename",
filename);
600 if (explicit_filename != empty_String)
601 filename = explicit_filename;
602 String explicit_extension = getAparameter<String>(stat_pset,
"extension", empty_String);
603 if (explicit_extension != empty_String) {
604 if (explicit_extension[0] ==
'.') {
605 filename += explicit_extension;
607 filename = filename +
"." + explicit_extension;
615 if ((filename !=
"cout") && (filename !=
"cerr")) {
617 if (filename.find(
'.') == npos) {
618 actual_filename +=
".log";
628 <<
"Duplicate name for a MessageLogger Statistics Destination: " << actual_filename <<
"\n";
631 <<
"Duplicate name for a MessageLogger Statistics Destination: " << actual_filename <<
"\n" 632 <<
"Only original configuration instructions are used";
643 bool statistics_destination_is_real = !no_statistics_configured;
646 if (actual_filename ==
"cout") {
648 }
else if (actual_filename ==
"cerr") {
651 auto os_sp = std::make_shared<std::ofstream>(actual_filename.c_str());
657 statistics_destination_is_real =
true;
661 if (statistics_destination_is_real) {
663 auto stat = std::make_shared<ELstatistics>(*os_p);
666 bool reset = getAparameter<bool>(stat_pset,
"reset",
false);
674 stat->noTerminationSummary();
686 cats.push_back(s.substr(i, j - i));
688 while ((i != npos) && (s[
i] ==
'|'))
708 sm[
"NoStatisticsDestinationsConfigured"] = 0.0;
void runCommand(MessageLoggerQ::OpCode opcode, void *operand) override
std::vector< std::shared_ptr< ELstatistics > > statisticsDestControls
std::vector< bool > statisticsResets
std::vector< edm::propagate_const< std::shared_ptr< std::ofstream > > > file_ps
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
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()
~ThreadSafeLogMessageLoggerScribe() override