43 m_clean_slate_configuration(
true),
47 m_messageBeingSent(
false),
48 m_waitingThreshold(100),
49 m_tooManyWaitingMessagesCount(0) {}
59 for (
unsigned int icat = 0; icat <
categories.size(); ++icat) {
82 ErrorObj* errorobj_p = static_cast<ErrorObj*>(operand);
89 std::cerr <<
"ThreadSafeLogMessageLoggerScribe caught " <<
m_count <<
" cms::Exceptions, text = \n"
93 cerr <<
"MessageLogger will no longer be processing "
94 <<
"messages due to errors (entering purge mode).\n";
98 std::cerr <<
"ThreadSafeLogMessageLoggerScribe caught an unknown exception and "
99 <<
"will no longer be processing "
100 <<
"messages. (entering purge mode)\n";
106 auto job_pset_p = std::unique_ptr<edm::ParameterSet>(
107 static_cast<edm::ParameterSet*>(operand));
113 assert(operand ==
nullptr);
117 std::cerr <<
"ThreadSafeLogMessageLoggerScribe caught exception "
118 <<
"during summarize:\n"
121 std::cerr <<
"ThreadSafeLogMessageLoggerScribe caught unkonwn exception type "
122 <<
"during summarize. (Ignored)\n";
127 std::string* jobMode_p = static_cast<std::string*>(operand);
138 assert(operand ==
nullptr);
146 std::string* cat_p = static_cast<std::string*>(operand);
152 std::map<std::string, double>* smp =
static_cast<std::map<std::string, double>*
>(operand);
161 bool expected =
false;
162 std::unique_ptr<ErrorObj>
obj(errorobj_p);
166 for (
unsigned int icat = 0; icat <
categories.size(); ++icat) {
171 errorobj_p =
nullptr;
173 obj.reset(errorobj_p);
176 for (
unsigned int icat = 0; icat <
categories.size(); ++icat) {
194 if (not
pset.exists(
"files") and
195 ((
pset.exists(
"destinations")
or pset.existsAs<std::vector<std::string>>(
"statistics",
true)
or
196 pset.existsAs<std::vector<std::string>>(
"statistics",
false)
or pset.exists(
"categories")))) {
204 auto itFound =
std::find(psets.begin(), psets.end(),
"default");
205 if (itFound != psets.end()) {
206 psets.erase(itFound);
209 return std::set<std::string>(psets.begin(), psets.end());
215 auto itFound =
std::find(psets.begin(), psets.end(),
"default");
216 if (itFound != psets.end()) {
218 psets.erase(itFound);
221 itFound =
std::find(psets.begin(), psets.end(),
"cout");
222 if (itFound != psets.end()) {
224 psets.erase(itFound);
227 itFound =
std::find(psets.begin(), psets.end(),
"cerr");
228 if (itFound != psets.end()) {
230 psets.erase(itFound);
237 categories.insert(psets.begin(), psets.end());
250 std::string filename_default = getAparameter<std::string>(dest_pset,
"output", empty_String);
251 if (filename_default == empty_String) {
253 if (filename_default == empty_String) {
258 std::string explicit_filename = getAparameter<std::string>(dest_pset,
"filename", filename_default);
259 if (explicit_filename != empty_String)
261 std::string explicit_extension = getAparameter<std::string>(dest_pset,
"extension", empty_String);
262 if (explicit_extension != empty_String) {
263 if (explicit_extension[0] ==
'.') {
272 if (
filename.find(
'.') == std::string::npos) {
281 auto preconfiguration_message =
283 if (not preconfiguration_message.empty()) {
289 LogError(
"preconfiguration") << preconfiguration_message;
293 LogWarning(
"multiLogConfig") <<
"The message logger has been configured multiple times";
299 auto categories = findAllCategories(job_pset);
310 if (cout_dest.getUntrackedParameter<
bool>(
"enable")) {
316 if (cerr_dest.getUntrackedParameter<
bool>(
"enable")) {
330 <<
"Duplicate name for a MessageLogger Destination: " << actual_filename <<
"\n"
331 <<
"Please modify the configuration to use unique file names.";
334 <<
"Duplicate name for a MessageLogger Destination: " << actual_filename <<
"\n"
335 <<
"Only original configuration instructions are used";
349 if (getAparameter<bool>(dest_pset,
"enableStatistics",
false)) {
356 if (not usingOldConfig(job_pset)) {
366 getAparameter<std::string>(job_pset,
"generate_preconfiguration_message", empty_String);
367 if (preconfiguration_message != empty_String) {
373 LogError(
"preconfiguration") << preconfiguration_message;
377 LogWarning(
"multiLogConfig") <<
"The message logger has been configured multiple times";
383 vString categories = getAparameter<vString>(job_pset,
"categories", empty_vString);
397 std::shared_ptr<ELdestination> dest_ctrl;
406 auto os_sp = std::make_shared<std::ofstream>(
filename.c_str());
408 dest_ctrl =
m_admin_p->attach(std::make_shared<ELoutput>(*os_sp));
436 edm::ParameterSet default_pset = getAparameter<edm::ParameterSet>(job_pset,
"default", empty_PSet);
437 returnValue.
limit_ = getAparameter<int>(
441 returnValue.
timespan_ = getAparameter<int>(
445 returnValue.
noLineBreaks_ = getAparameter<bool>(default_pset,
"noLineBreaks",
false);
446 returnValue.
lineLength_ = getAparameter<int>(default_pset,
"lineLength", 80);
447 returnValue.
noTimeStamps_ = getAparameter<bool>(default_pset,
"noTimeStamps",
false);
455 std::shared_ptr<ELdestination> dest_ctrl,
463 const std::string COMMON_DEFAULT_THRESHOLD =
"INFO";
465 vString const severities = {{
"WARNING",
"INFO",
"FWKINFO",
"ERROR",
"DEBUG"}};
473 edm::ParameterSet const default_pset = getAparameter<edm::ParameterSet>(job_pset,
"default", empty_PSet);
476 bool is_placeholder = getAparameter<bool>(dest_pset,
"placeholder",
false);
481 edm::ParameterSet dest_default_pset = getAparameter<edm::ParameterSet>(dest_pset,
"default", empty_PSet);
482 int dest_default_limit = getAparameter<int>(dest_default_pset,
"limit",
defaults.limit_);
483 int dest_default_interval = getAparameter<int>(dest_default_pset,
"reportEvery",
defaults.reportEvery_);
485 int dest_default_timespan = getAparameter<int>(dest_default_pset,
"timespan",
defaults.timespan_);
487 if (dest_default_limit !=
defaults.NO_VALUE_SET) {
488 if (dest_default_limit < 0)
489 dest_default_limit = 2000000000;
490 dest_ctrl->setLimit(
"*", dest_default_limit);
492 if (dest_default_interval !=
defaults.NO_VALUE_SET) {
493 dest_ctrl->setInterval(
"*", dest_default_interval);
495 if (dest_default_timespan !=
defaults.NO_VALUE_SET) {
496 if (dest_default_timespan < 0)
497 dest_default_timespan = 2000000000;
498 dest_ctrl->setTimespan(
"*", dest_default_timespan);
503 if (dest_threshold == empty_String) {
506 if (dest_threshold == empty_String) {
507 dest_threshold =
defaults.threshold_;
509 if (dest_threshold == empty_String) {
512 if (dest_threshold == empty_String)
513 dest_threshold = COMMON_DEFAULT_THRESHOLD;
515 dest_ctrl->setThreshold(threshold_sev);
517 setGlobalThresholds(threshold_sev);
523 getAparameter<edm::ParameterSet>(default_pset, msgID, empty_PSet);
524 edm::ParameterSet category_pset = getAparameter<edm::ParameterSet>(dest_pset, msgID, default_category_pset);
526 int category_default_limit = getAparameter<int>(default_category_pset,
"limit",
defaults.NO_VALUE_SET);
527 int limit = getAparameter<int>(category_pset,
"limit", category_default_limit);
529 limit = dest_default_limit;
531 int category_default_interval = getAparameter<int>(default_category_pset,
"reportEvery",
defaults.NO_VALUE_SET);
532 int interval = getAparameter<int>(category_pset,
"reportEvery", category_default_interval);
536 int category_default_timespan = getAparameter<int>(default_category_pset,
"timespan",
defaults.NO_VALUE_SET);
537 int timespan = getAparameter<int>(category_pset,
"timespan", category_default_timespan);
538 if (timespan ==
defaults.NO_VALUE_SET)
539 timespan = dest_default_timespan;
549 if (timespan ==
defaults.NO_VALUE_SET) {
556 dest_ctrl->setLimit(msgID,
limit);
559 dest_ctrl->setInterval(msgID,
interval);
561 if (timespan !=
defaults.NO_VALUE_SET) {
563 timespan = 2000000000;
564 dest_ctrl->setTimespan(msgID, timespan);
570 for (vString::const_iterator sev_it = severities.begin(); sev_it != severities.end(); ++sev_it) {
573 edm::ParameterSet default_sev_pset = getAparameter<edm::ParameterSet>(default_pset, sevID, empty_PSet);
574 edm::ParameterSet sev_pset = getAparameter<edm::ParameterSet>(dest_pset, sevID, default_sev_pset);
576 int limit = getAparameter<int>(sev_pset,
"limit",
defaults.NO_VALUE_SET);
585 int interval = getAparameter<int>(sev_pset,
"reportEvery",
defaults.NO_VALUE_SET);
592 int timespan = getAparameter<int>(sev_pset,
"timespan",
defaults.NO_VALUE_SET);
593 if (timespan ==
defaults.NO_VALUE_SET) {
596 if (timespan !=
defaults.NO_VALUE_SET) {
598 timespan = 2000000000;
599 dest_ctrl->setTimespan(
severity, timespan);
607 dest_ctrl->setLineLength(32000);
610 int lineLen = getAparameter<int>(dest_pset,
"lineLength",
defaults.lineLength_);
611 dest_ctrl->setLineLength(lineLen);
615 bool suppressTime = getAparameter<bool>(dest_pset,
"noTimeStamps",
defaults.noTimeStamps_);
617 dest_ctrl->suppressTime();
648 std::vector<std::string> ordinary_destination_filenames;
654 edm::ParameterSet dest_pset = getAparameter<edm::ParameterSet>(job_pset, psetname, empty_PSet);
655 bool is_placeholder = getAparameter<bool>(dest_pset,
"placeholder",
false);
676 <<
"Duplicate name for a MessageLogger Destination: " << actual_filename <<
"\n"
677 <<
"Only the first configuration instructions are used";
681 <<
"Duplicate name for a MessageLogger Destination: " << actual_filename <<
"\n"
682 <<
"Only original configuration instructions are used";
687 ordinary_destination_filenames.push_back(actual_filename);
696 return ordinary_destination_filenames;
707 auto stat = std::make_shared<ELstatistics>(*os_p);
710 bool reset = getAparameter<bool>(stat_pset,
"resetStatistics",
false);
713 reset = getAparameter<bool>(stat_pset,
"reset",
false);
721 if (not dest_threshold.empty()) {
723 stat->setThreshold(threshold_sev);
725 setGlobalThresholds(threshold_sev);
730 stat->noTerminationSummary();
736 vString const& ordinary_destination_filenames) {
742 vString statistics = getAparameter<vString>(job_pset,
"statistics", empty_vString);
744 bool no_statistics_configured =
statistics.empty();
746 if (no_statistics_configured) {
754 no_statistics_configured =
statistics.empty();
758 if (getAparameter<bool>(stat_pset,
"enableStatistics",
false)) {
768 edm::ParameterSet stat_pset = getAparameter<edm::ParameterSet>(job_pset, psetname, empty_PSet);
769 bool is_placeholder = getAparameter<bool>(stat_pset,
"placeholder",
false);
786 std::string explicit_filename = getAparameter<std::string>(stat_pset,
"filename",
filename);
787 if (explicit_filename != empty_String)
789 std::string explicit_extension = getAparameter<std::string>(stat_pset,
"extension", empty_String);
790 if (explicit_extension != empty_String) {
791 if (explicit_extension[0] ==
'.') {
805 actual_filename +=
".log";
811 if (!
search_all(ordinary_destination_filenames, actual_filename)) {
815 <<
"Duplicate name for a MessageLogger Statistics Destination: " << actual_filename <<
"\n";
818 <<
"Duplicate name for a MessageLogger Statistics Destination: " << actual_filename <<
"\n"
819 <<
"Only original configuration instructions are used";
830 bool statistics_destination_is_real = !no_statistics_configured;
833 if (actual_filename ==
"cout") {
835 }
else if (actual_filename ==
"cerr") {
838 auto os_sp = std::make_shared<std::ofstream>(actual_filename.c_str());
844 statistics_destination_is_real =
true;
847 if (statistics_destination_is_real) {
862 cats.push_back(
s.substr(
i,
j -
i));
864 while ((
i != npos) && (
s[
i] ==
'|'))
884 sm[
"NoStatisticsDestinationsConfigured"] = 0.0;
894 topDesc.
addUntracked<
bool>(
"messageSummaryToJobReport",
false);
896 topDesc.
addUntracked<
unsigned int>(
"waiting_threshold", 100);
897 topDesc.
addUntracked<std::vector<std::string>>(
"suppressDebug", {});
898 topDesc.
addUntracked<std::vector<std::string>>(
"suppressInfo", {});
899 topDesc.
addUntracked<std::vector<std::string>>(
"suppressFwkInfo", {});
900 topDesc.
addUntracked<std::vector<std::string>>(
"suppressWarning", {});
901 topDesc.
addUntracked<std::vector<std::string>>(
"suppressError", {});
902 topDesc.
addUntracked<std::vector<std::string>>(
"debugModules", {});
905 category.addUntracked<
int>(
"reportEvery", 1);
908 "Set a limit on the number of messages of this category. The default value is used to denote no "
910 category.addOptionalUntracked<
int>(
"timespan");
914 destination_base.addOptionalUntracked<
bool>(
"noTimeStamps");
915 destination_base.addOptionalUntracked<
int>(
"lineLength");
916 destination_base.addOptionalUntracked<
std::string>(
"threshold");
917 destination_base.addOptionalUntracked<
std::string>(
"statisticsThreshold");
920 catnode.setComment(
"Specialize either a category or any of 'DEBUG', 'INFO', 'FWKINFO', 'WARNING' or 'ERROR'");
921 destination_base.addNode(catnode);
924 destination_noStats.addUntracked<
bool>(
"enableStatistics",
false);
925 destination_noStats.addUntracked<
bool>(
"resetStatistics",
false);
932 "Set a limit on the number of messages of this category. The default value is used to denote no "
943 cerr_destination.addUntracked<
bool>(
"enableStatistics",
true);
944 cerr_destination.addUntracked<
bool>(
"resetStatistics",
false);
945 cerr_destination.addUntracked<
bool>(
"enable",
true);
948 cout_destination.addUntracked<
bool>(
"enable",
false);
952 fileDestination.addOptionalUntracked<
std::string>(
"output");
953 fileDestination.addOptionalUntracked<
std::string>(
"filename");
954 fileDestination.addOptionalUntracked<
std::string>(
"extension");
958 files.addNode(fileWildcard);
960 std::map<std::string, edm::ParameterSetDescription> standards = {
961 {
"cerr", cerr_destination}, {
"cout", cout_destination}, {
"default", default_pset}, {
"files",
files}};
967 config.addDefault(topDesc);
973 if (usingOldConfig(
pset))
975 if (not
pset.exists(
"files") and
976 ((
pset.exists(
"destinations")
or pset.existsAs<std::vector<std::string>>(
"statistics",
true)
or
977 pset.existsAs<std::vector<std::string>>(
"statistics",
false)
or pset.exists(
"categories")))) {