41 ThreadSafeLogMessageLoggerScribe::ThreadSafeLogMessageLoggerScribe()
44 m_clean_slate_configuration(
true),
48 m_messageBeingSent(
false),
49 m_waitingThreshold(100),
50 m_tooManyWaitingMessagesCount(0) {}
60 for (
unsigned int icat = 0; icat <
categories.size(); ++icat) {
90 std::cerr <<
"ThreadSafeLogMessageLoggerScribe caught " <<
m_count <<
" cms::Exceptions, text = \n" 94 cerr <<
"MessageLogger will no longer be processing " 95 <<
"messages due to errors (entering purge mode).\n";
99 std::cerr <<
"ThreadSafeLogMessageLoggerScribe caught an unknown exception and " 100 <<
"will no longer be processing " 101 <<
"messages. (entering purge mode)\n";
107 auto job_pset_p = std::unique_ptr<edm::ParameterSet>(
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) {
172 errorobj_p =
nullptr;
174 obj.reset(errorobj_p);
177 for (
unsigned int icat = 0; icat <
categories.size(); ++icat) {
195 if (not
pset.exists(
"files") and
196 ((
pset.exists(
"destinations")
or pset.existsAs<std::vector<std::string>>(
"statistics",
true)
or 197 pset.existsAs<std::vector<std::string>>(
"statistics",
false)
or pset.exists(
"categories")))) {
205 auto itFound =
std::find(psets.begin(), psets.end(),
"default");
206 if (itFound != psets.end()) {
207 psets.erase(itFound);
210 return std::set<std::string>(psets.begin(), psets.end());
216 auto itFound =
std::find(psets.begin(), psets.end(),
"default");
217 if (itFound != psets.end()) {
219 psets.erase(itFound);
222 itFound =
std::find(psets.begin(), psets.end(),
"cout");
223 if (itFound != psets.end()) {
225 psets.erase(itFound);
228 itFound =
std::find(psets.begin(), psets.end(),
"cerr");
229 if (itFound != psets.end()) {
231 psets.erase(itFound);
238 categories.insert(psets.begin(), psets.end());
251 std::string filename_default = getAparameter<std::string>(dest_pset,
"output", empty_String);
252 if (filename_default == empty_String) {
254 if (filename_default == empty_String) {
259 std::string explicit_filename = getAparameter<std::string>(dest_pset,
"filename", filename_default);
260 if (explicit_filename != empty_String)
262 std::string explicit_extension = getAparameter<std::string>(dest_pset,
"extension", empty_String);
263 if (explicit_extension != empty_String) {
264 if (explicit_extension[0] ==
'.') {
273 if (
filename.find(
'.') == std::string::npos) {
282 auto preconfiguration_message =
284 if (not preconfiguration_message.empty()) {
290 LogError(
"preconfiguration") << preconfiguration_message;
294 LogWarning(
"multiLogConfig") <<
"The message logger has been configured multiple times";
300 auto categories = findAllCategories(job_pset);
311 if (cout_dest.getUntrackedParameter<
bool>(
"enable")) {
317 if (cerr_dest.getUntrackedParameter<
bool>(
"enable")) {
331 <<
"Duplicate name for a MessageLogger Destination: " << actual_filename <<
"\n" 332 <<
"Please modify the configuration to use unique file names.";
335 <<
"Duplicate name for a MessageLogger Destination: " << actual_filename <<
"\n" 336 <<
"Only original configuration instructions are used";
350 if (getAparameter<bool>(dest_pset,
"enableStatistics",
false)) {
354 if (cout_dest.getUntrackedParameter<
bool>(
"enable") and
355 getAparameter<bool>(cout_dest,
"enableStatistics",
true)) {
358 if (cerr_dest.getUntrackedParameter<
bool>(
"enable") and
359 getAparameter<bool>(cerr_dest,
"enableStatistics",
true)) {
365 if (not usingOldConfig(job_pset)) {
375 getAparameter<std::string>(job_pset,
"generate_preconfiguration_message", empty_String);
376 if (preconfiguration_message != empty_String) {
382 LogError(
"preconfiguration") << preconfiguration_message;
386 LogWarning(
"multiLogConfig") <<
"The message logger has been configured multiple times";
392 vString categories = getAparameter<vString>(job_pset,
"categories", empty_vString);
406 std::shared_ptr<ELdestination> dest_ctrl;
415 auto os_sp = std::make_shared<std::ofstream>(
filename.c_str());
417 dest_ctrl =
m_admin_p->attach(std::make_shared<ELoutput>(*os_sp));
445 edm::ParameterSet default_pset = getAparameter<edm::ParameterSet>(job_pset,
"default", empty_PSet);
446 returnValue.
limit_ = getAparameter<int>(
450 returnValue.
timespan_ = getAparameter<int>(
454 returnValue.
noLineBreaks_ = getAparameter<bool>(default_pset,
"noLineBreaks",
false);
455 returnValue.
lineLength_ = getAparameter<int>(default_pset,
"lineLength", 80);
456 returnValue.
noTimeStamps_ = getAparameter<bool>(default_pset,
"noTimeStamps",
false);
464 std::shared_ptr<ELdestination> dest_ctrl,
472 const std::string COMMON_DEFAULT_THRESHOLD =
"INFO";
474 vString const severities = {{
"WARNING",
"INFO",
"FWKINFO",
"ERROR",
"DEBUG"}};
482 edm::ParameterSet const default_pset = getAparameter<edm::ParameterSet>(job_pset,
"default", empty_PSet);
485 bool is_placeholder = getAparameter<bool>(dest_pset,
"placeholder",
false);
490 edm::ParameterSet dest_default_pset = getAparameter<edm::ParameterSet>(dest_pset,
"default", empty_PSet);
491 int dest_default_limit = getAparameter<int>(dest_default_pset,
"limit",
defaults.limit_);
492 int dest_default_interval = getAparameter<int>(dest_default_pset,
"reportEvery",
defaults.reportEvery_);
494 int dest_default_timespan = getAparameter<int>(dest_default_pset,
"timespan",
defaults.timespan_);
496 if (dest_default_limit !=
defaults.NO_VALUE_SET) {
497 if (dest_default_limit < 0)
498 dest_default_limit = 2000000000;
499 dest_ctrl->setLimit(
"*", dest_default_limit);
501 if (dest_default_interval !=
defaults.NO_VALUE_SET) {
502 dest_ctrl->setInterval(
"*", dest_default_interval);
504 if (dest_default_timespan !=
defaults.NO_VALUE_SET) {
505 if (dest_default_timespan < 0)
506 dest_default_timespan = 2000000000;
507 dest_ctrl->setTimespan(
"*", dest_default_timespan);
512 if (dest_threshold == empty_String) {
515 if (dest_threshold == empty_String) {
516 dest_threshold =
defaults.threshold_;
518 if (dest_threshold == empty_String) {
521 if (dest_threshold == empty_String)
522 dest_threshold = COMMON_DEFAULT_THRESHOLD;
524 dest_ctrl->setThreshold(threshold_sev);
526 setGlobalThresholds(threshold_sev);
532 getAparameter<edm::ParameterSet>(default_pset, msgID, empty_PSet);
533 edm::ParameterSet category_pset = getAparameter<edm::ParameterSet>(dest_pset, msgID, default_category_pset);
535 int category_default_limit = getAparameter<int>(default_category_pset,
"limit",
defaults.NO_VALUE_SET);
536 int limit = getAparameter<int>(category_pset,
"limit", category_default_limit);
538 limit = dest_default_limit;
540 int category_default_interval = getAparameter<int>(default_category_pset,
"reportEvery",
defaults.NO_VALUE_SET);
541 int interval = getAparameter<int>(category_pset,
"reportEvery", category_default_interval);
545 int category_default_timespan = getAparameter<int>(default_category_pset,
"timespan",
defaults.NO_VALUE_SET);
546 int timespan = getAparameter<int>(category_pset,
"timespan", category_default_timespan);
565 dest_ctrl->setLimit(msgID,
limit);
568 dest_ctrl->setInterval(msgID,
interval);
573 dest_ctrl->setTimespan(msgID,
timespan);
579 for (vString::const_iterator sev_it = severities.begin(); sev_it != severities.end(); ++sev_it) {
582 edm::ParameterSet default_sev_pset = getAparameter<edm::ParameterSet>(default_pset, sevID, empty_PSet);
583 edm::ParameterSet sev_pset = getAparameter<edm::ParameterSet>(dest_pset, sevID, default_sev_pset);
585 int limit = getAparameter<int>(sev_pset,
"limit",
defaults.NO_VALUE_SET);
594 int interval = getAparameter<int>(sev_pset,
"reportEvery",
defaults.NO_VALUE_SET);
601 int timespan = getAparameter<int>(sev_pset,
"timespan",
defaults.NO_VALUE_SET);
616 dest_ctrl->setLineLength(32000);
619 int lineLen = getAparameter<int>(dest_pset,
"lineLength",
defaults.lineLength_);
620 dest_ctrl->setLineLength(lineLen);
624 bool suppressTime = getAparameter<bool>(dest_pset,
"noTimeStamps",
defaults.noTimeStamps_);
626 dest_ctrl->suppressTime();
657 std::vector<std::string> ordinary_destination_filenames;
663 edm::ParameterSet dest_pset = getAparameter<edm::ParameterSet>(job_pset, psetname, empty_PSet);
664 bool is_placeholder = getAparameter<bool>(dest_pset,
"placeholder",
false);
685 <<
"Duplicate name for a MessageLogger Destination: " << actual_filename <<
"\n" 686 <<
"Only the first configuration instructions are used";
690 <<
"Duplicate name for a MessageLogger Destination: " << actual_filename <<
"\n" 691 <<
"Only original configuration instructions are used";
696 ordinary_destination_filenames.push_back(actual_filename);
705 return ordinary_destination_filenames;
716 auto stat = std::make_shared<ELstatistics>(*os_p);
719 bool reset = getAparameter<bool>(stat_pset,
"resetStatistics",
false);
722 reset = getAparameter<bool>(stat_pset,
"reset",
false);
730 if (not dest_threshold.empty()) {
732 stat->setThreshold(threshold_sev);
734 setGlobalThresholds(threshold_sev);
739 stat->noTerminationSummary();
745 vString const& ordinary_destination_filenames) {
751 vString statistics = getAparameter<vString>(job_pset,
"statistics", empty_vString);
753 bool no_statistics_configured =
statistics.empty();
755 if (no_statistics_configured) {
763 no_statistics_configured =
statistics.empty();
767 if (getAparameter<bool>(stat_pset,
"enableStatistics",
false)) {
777 edm::ParameterSet stat_pset = getAparameter<edm::ParameterSet>(job_pset, psetname, empty_PSet);
778 bool is_placeholder = getAparameter<bool>(stat_pset,
"placeholder",
false);
795 std::string explicit_filename = getAparameter<std::string>(stat_pset,
"filename",
filename);
796 if (explicit_filename != empty_String)
798 std::string explicit_extension = getAparameter<std::string>(stat_pset,
"extension", empty_String);
799 if (explicit_extension != empty_String) {
800 if (explicit_extension[0] ==
'.') {
814 actual_filename +=
".log";
820 if (!
search_all(ordinary_destination_filenames, actual_filename)) {
824 <<
"Duplicate name for a MessageLogger Statistics Destination: " << actual_filename <<
"\n";
827 <<
"Duplicate name for a MessageLogger Statistics Destination: " << actual_filename <<
"\n" 828 <<
"Only original configuration instructions are used";
839 bool statistics_destination_is_real = !no_statistics_configured;
842 if (actual_filename ==
"cout") {
844 }
else if (actual_filename ==
"cerr") {
847 auto os_sp = std::make_shared<std::ofstream>(actual_filename.c_str());
853 statistics_destination_is_real =
true;
856 if (statistics_destination_is_real) {
871 cats.push_back(
s.substr(
i,
j -
i));
873 while ((
i != npos) && (
s[
i] ==
'|'))
893 sm[
"NoStatisticsDestinationsConfigured"] = 0.0;
903 topDesc.
addUntracked<
bool>(
"messageSummaryToJobReport",
false);
905 topDesc.
addUntracked<
unsigned int>(
"waiting_threshold", 100);
906 topDesc.
addUntracked<std::vector<std::string>>(
"suppressDebug", {});
907 topDesc.
addUntracked<std::vector<std::string>>(
"suppressInfo", {});
908 topDesc.
addUntracked<std::vector<std::string>>(
"suppressFwkInfo", {});
909 topDesc.
addUntracked<std::vector<std::string>>(
"suppressWarning", {});
910 topDesc.
addUntracked<std::vector<std::string>>(
"suppressError", {});
911 topDesc.
addUntracked<std::vector<std::string>>(
"debugModules", {});
914 category.addUntracked<
int>(
"reportEvery", 1);
917 "Set a limit on the number of messages of this category. The default value is used to denote no " 919 category.addOptionalUntracked<
int>(
"timespan");
923 destination_base.addOptionalUntracked<
bool>(
"noTimeStamps");
924 destination_base.addOptionalUntracked<
int>(
"lineLength");
925 destination_base.addOptionalUntracked<
std::string>(
"threshold");
926 destination_base.addOptionalUntracked<
std::string>(
"statisticsThreshold");
929 catnode.setComment(
"Specialize either a category or any of 'DEBUG', 'INFO', 'FWKINFO', 'WARNING' or 'ERROR'");
930 destination_base.addNode(catnode);
933 destination_noStats.addUntracked<
bool>(
"enableStatistics",
false);
934 destination_noStats.addUntracked<
bool>(
"resetStatistics",
false);
941 "Set a limit on the number of messages of this category. The default value is used to denote no " 952 cerr_destination.addUntracked<
bool>(
"enableStatistics",
true);
953 cerr_destination.addUntracked<
bool>(
"resetStatistics",
false);
954 cerr_destination.addUntracked<
bool>(
"enable",
true);
957 cout_destination.addUntracked<
bool>(
"enable",
false);
961 fileDestination.addOptionalUntracked<
std::string>(
"output");
962 fileDestination.addOptionalUntracked<
std::string>(
"filename");
963 fileDestination.addOptionalUntracked<
std::string>(
"extension");
967 files.addNode(fileWildcard);
969 std::map<std::string, edm::ParameterSetDescription> standards = {
970 {
"cerr", cerr_destination}, {
"cout", cout_destination}, {
"default", default_pset}, {
"files",
files}};
976 config.addDefault(topDesc);
982 if (usingOldConfig(
pset))
984 if (not
pset.exists(
"files") and
985 ((
pset.exists(
"destinations")
or pset.existsAs<std::vector<std::string>>(
"statistics",
true)
or 986 pset.existsAs<std::vector<std::string>>(
"statistics",
false)
or pset.exists(
"categories")))) {
void runCommand(MessageLoggerQ::OpCode opcode, void *operand) override
bool m_clean_slate_configuration
std::atomic< bool > m_purge_mode
ParameterDescriptionBase * addUntracked(U const &iLabel, T const &value)
std::string destinationFileName(edm::ParameterSet const &, std::string const &) const
void configure_errorlog_new(edm::ParameterSet &)
void validate(edm::ParameterSet &) const
void triggerStatisticsSummaries()
ParameterDescriptionNode * addNode(ParameterDescriptionNode const &node)
Log< level::Error, false > LogError
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
constexpr const ELseverityLevel ELhighestSeverity
void triggerFJRmessageSummary(std::map< std::string, double > &sm)
static constexpr int COMMON_DEFAULT_TIMESPAN
std::atomic< int > m_count
static bool debugAlwaysSuppressed
T getUntrackedParameter(std::string const &, T const &) const
std::vector< edm::propagate_const< std::shared_ptr< std::ofstream > > > m_file_ps
size_t m_waitingThreshold
oneapi::tbb::concurrent_queue< ErrorObj * > m_waitingMessages
The Signals That Services Can Subscribe To This is based on ActivityRegistry and is current per Services can connect to the signals distributed by the ActivityRegistry in order to monitor the activity of the application Each possible callback has some defined which we here list in angle e< void, edm::EventID const &, edm::Timestamp const & > We also list in braces which AR_WATCH_USING_METHOD_ is used for those or
static ConfigurableDefaults parseDefaults(edm::ParameterSet const &job_pset)
void configure_statistics_dest(edm::ParameterSet const &job_pset, ConfigurableDefaults const &defaults, vString const &categories, edm::ParameterSet const &stat_pset, std::string const &psetname, std::string const &filename)
std::atomic< bool > m_messageBeingSent
const ELextendedID & xid() const
static constexpr int COMMON_DEFAULT_LIMIT
static void noteGroupedCategory(std::string const &cat)
std::atomic< unsigned long > m_tooManyWaitingMessagesCount
std::map< std::string, edm::propagate_const< std::ostream * > > m_stream_ps
static bool warningAlwaysSuppressed
edm::propagate_const< std::shared_ptr< ELadministrator > > m_admin_p
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
std::vector< std::shared_ptr< ELstatistics > > m_statisticsDestControls
std::vector< bool > m_statisticsResets
bool search_all(ForwardSequence const &s, Datum const &d)
static edm::JobMode mode(std::string const &jm)
constexpr const ELseverityLevel ELzeroSeverity
static bool fwkInfoAlwaysSuppressed
static constexpr int COMMON_DEFAULT_INTERVAL
value_ptr< MessageLoggerDefaults > m_messageLoggerDefaults
static constexpr int NO_VALUE_SET
Func copy_all(ForwardSequence &s, Func f)
wrappers for copy
std::vector< std::string > configure_ordinary_destinations(edm::ParameterSet const &, ConfigurableDefaults const &defaults, vString const &categories)
virtual void setID(std::string_view ID)
void log(ErrorObj *errorobj_p)
void parseCategories(std::string const &s, std::vector< std::string > &cats)
void configure_statistics(edm::ParameterSet const &, ConfigurableDefaults const &defaults, vString const &categories, std::vector< std::string > const &destination_names)
std::vector< std::string > vString
ParameterDescriptionBase * addOptionalUntracked(U const &iLabel, T const &value)
std::shared_ptr< ELdestination > makeDestinationCtrl(std::string const &filename)
Log< level::Warning, false > LogWarning
void configure_dest(edm::ParameterSet const &job_pset, ConfigurableDefaults const &, vString const &categories, std::shared_ptr< ELdestination > dest_ctrl, edm::ParameterSet const &dest_pset, std::string const &filename)
static bool infoAlwaysSuppressed
void reset(double vett[256])
std::shared_ptr< ELdestination > m_early_dest
void configure_errorlog(edm::ParameterSet &)
~ThreadSafeLogMessageLoggerScribe() override