27 using std::make_unique;
33 bool constexpr throw_on_clean_slate [[gnu::unused]] {
true};
34 bool constexpr no_throw_on_clean_slate [[gnu::unused]] {
false};
48 " filename: \"err.log\"" 60 MessageLoggerScribe::MessageLoggerScribe(
72 std::string msg{
"\nConfiguration error for destination: " +
86 errorobj_p->
setID(cat);
108 auto errorobj_p =
static_cast<ErrorObj*
>(operand);
116 std::cerr <<
"MessageLoggerScribe caught " <<
count_ 117 <<
" cet::exceptions, text = \n" 121 std::cerr <<
"MessageLogger will no longer be processing " 122 <<
"messages due to errors (entering purge mode).\n";
127 std::cerr <<
"MessageLoggerScribe caught an unknown exception and " 128 <<
"will no longer be processing " 129 <<
"messages. (entering purge mode)\n";
135 auto config = std::unique_ptr<MessageLoggerQ::Config>(
141 assert(operand ==
nullptr);
146 std::cerr <<
"MessageLoggerScribe caught exception " 147 <<
"during summarize:\n" 151 std::cerr <<
"MessageLoggerScribe caught unkonwn exception type " 152 <<
"during summarize. (Ignored)\n";
157 assert(operand ==
nullptr);
197 std::unique_ptr<ErrorObj> obj(errorobj_p);
201 errorobj_p->
setID(cat);
205 errorobj_p =
nullptr;
207 obj.reset(errorobj_p);
209 errorobj_p->
setID(cat);
223 std::unique_ptr<MessageLoggerQ::Config>&&
config)
227 <<
"The message logger has been configured multiple times";
237 std::unique_ptr<MessageLoggerQ::Config>
config)
241 if (!config->destinations.get_if_present(dest_psets)) {
244 ordinaryDests = dest_psets;
245 ordinaryDests.
erase(
"statistics");
252 "statistics", default_statistics_config(ordinaryDests));
269 std::set<std::string> ids;
271 std::vector<std::string> config_errors;
279 if (dest_pset.is_empty()) {
287 if (!dest_pset.get_if_present(
"type", dest_type)) {
289 <<
"No 'type' specified for destination '" << psetname <<
"'.\n";
293 bool const throw_on_duplicate_id =
296 createId(ids, dest_type, psetname, dest_pset, throw_on_duplicate_id);
300 outputId, configuration, no_throw_on_clean_slate))
312 makePlugin_(plugin_factory, libspec, psetname, dest_pset));
320 std::string msg{
"Configuration error for destination: " +
323 config_errors.push_back(std::move(msg));
327 if (!config_errors.empty()) {
328 std::string msg{
"\nThe following messagefacility destinations have " 329 "configuration errors:\n\n"};
333 auto start = cbegin(config_errors);
336 for (
auto it =
start, e = cend(config_errors); it !=
e; ++it) {
356 auto const npos = s.length();
357 decltype(s.length())
i{};
366 auto const j = s.find(
'|',
i);
370 while ((
i < npos) && (s[
i] ==
'|'))
382 auto&
dest = *idDestPair.second;
384 if (
dest.resetStats())
395 bool const should_throw)
398 if (!
cet::search_all(std::vector<std::string>{
"cout",
"cerr",
"syslog"},
404 if (!existing_ids.emplace(output_id).second) {
410 <<
" Output identifier: \"" << output_id <<
"\"" 411 <<
" already specified within ordinary/statistics block in FHiCL " 425 bool const should_throw)
428 switch (configuration) {
430 config_str =
"MessageLogger";
433 config_str =
"MessageLogger Statistics";
442 std::string const hrule{
"\n==============================================" 443 "============================== \n"};
444 std::ostringstream except_msg, orig_config_msg;
445 except_msg << hrule <<
"\n Duplicate name for a " << config_str
446 <<
" destination: \"" << output_id <<
"\"";
448 <<
"\n Only original configuration instructions are used. \n" 460 dest_pr->second->userWantsStats();
472 << except_msg.str() << orig_config_msg.str();
476 << except_msg.str() << orig_config_msg.str();
483 std::unique_ptr<ELdestination>
489 std::unique_ptr<ELdestination> result;
491 auto const pluginType = plugin_factory.
pluginType(libspec);
493 result = plugin_factory.
makePlugin<std::unique_ptr<ELdestination>>(
494 libspec, psetname, pset);
497 <<
"unrecognized plugin type " << pluginType <<
"for plugin " 503 <<
"Exception caught while processing plugin spec.\n";
MaybeLogger_< ELseverityLevel::ELsev_warning, false, true, detail::ConditionalLogger > LogWarning
ELextendedID const & xid() const
std::atomic< bool > purgeMode_
void configure_errorlog(std::unique_ptr< MessageLoggerQ::Config > &&dests_config)
std::atomic< int > count_
void triggerStatisticsSummaries()
void runCommand(OpCode opcode, void *operand) override
std::string pluginType(std::string const &libspec)
void checkType(std::string const &type, dest_config const configuration)
void setPID(long pid) override
cet::BasicPluginFactory pluginFactory_
void make_ParameterSet(intermediate_table const &tbl, ParameterSet &ps)
std::enable_if_t< std::is_base_of< ELdestination, DEST >::value, ELdestination & > attach(std::string const &outputId, std::unique_ptr< DEST > &&dest)
std::string trim_copy(std::string source, std::string const &t=" ")
virtual void setID(const std::string &ID)
std::vector< std::string > vstring
ELslProxy< ELhighestSeverityGen > constexpr ELhighestSeverity
list dests
Define destination.
std::string bold_fontify(std::string const &s)
static bool warningAlwaysSuppressed
std::string createId(std::set< std::string > &existing_ids, std::string const &type, std::string const &filename, fhicl::ParameterSet const &pset={}, bool const should_throw=true)
void setApplication(std::string const &application)
cet::coded_exception< errors::error, detail::translate > Exception
std::vector< std::string > get_pset_names() const
bool search_all(FwdCont const &, Datum const &)
destination_collection_t const & destinations() const
T get(std::string const &key) const
std::vector< std::string > parseCategories(std::string const &s)
static bool debugAlwaysSuppressed
MaybeLogger_< ELseverityLevel::ELsev_error, false, true, detail::AlwaysLogger > LogError
bool cleanSlateConfiguration_
static bool infoAlwaysSuppressed
cet::BasicPluginFactory pluginStatsFactory_
std::string const & id() const
auto default_destination_config()
void setHostName(std::string const &hostName) override
virtual void noTerminationSummary()
std::unique_ptr< ELdestination > makePlugin_(cet::BasicPluginFactory &pluginFactory, std::string const &libspec, std::string const &psetname, fhicl::ParameterSet const &pset)
char const * what() const noexcept override
void log(ErrorObj *errorobj_p)
std::enable_if_t<!std::is_function< RESULT_TYPE >::value, RESULT_TYPE > makePlugin(std::string const &libspec, ARGS &&...args)
bool erase(std::string const &key)
void setThreshold(ELseverityLevel sv)
tbb::concurrent_queue< ErrorObj * > waitingMessages_
void setApplication(std::string const &application) override
bool duplicateDestination(std::string const &output_id, ELdestConfig::dest_config const config, bool const should_throw)
void setHostAddr(std::string const &hostAddr) override
auto default_destinations_config()
void fetchDestinations(std::unique_ptr< MessageLoggerQ::Config > dests_config)
cet::coded_exception< error, detail::translate > exception
void makeDestinations(fhicl::ParameterSet const &dests, ELdestConfig::dest_config const config)
std::atomic< bool > messageBeingSent_
ELdestination & earlyDest_