LArSoft  v09_90_00
Liquid Argon Software toolkit - https://larsoft.org/
mf::service::ELostreamOutput Class Reference

#include "ELostreamOutput.h"

Inheritance diagram for mf::service::ELostreamOutput:
mf::service::ELdestination

Classes

struct  Config
 

Public Types

using Parameters = fhicl::WrappedTable< Config >
 
enum  flag_enum {
  NO_LINE_BREAKS, TIMESTAMP, MILLISECOND, MODULE,
  SUBROUTINE, TEXT, SOME_CONTEXT, SERIAL,
  FULL_CONTEXT, TIME_SEPARATE, EPILOGUE_SEPARATE, NFLAGS
}
 

Public Member Functions

 ~ELostreamOutput ()
 
 ELostreamOutput (Parameters const &config, cet::ostream_handle &&, bool emitAtStart=false)
 
 ELostreamOutput (Parameters const &config, std::ostream &, bool emitAtStart=false)
 
 ELostreamOutput (Config const &config, cet::ostream_handle &&, bool emitAtStart=false)
 
 ELostreamOutput (ELostreamOutput const &)=delete
 
 ELostreamOutput (ELostreamOutput &&)=delete
 
ELostreamOutputoperator= (ELostreamOutput const &)=delete
 
ELostreamOutputoperator= (ELostreamOutput &&)=delete
 
void setThreshold (ELseverityLevel sv)
 
virtual void log (mf::ErrorObj &)
 
virtual void finish ()
 
virtual void summary ()
 

Protected Member Functions

std::string summarizeContext (std::string const &)
 
void emitToken (std::ostream &os, std::string const &s, bool nl=false, bool preambleMode=false)
 
std::string formSummary ()
 
bool skipMsg (ELextendedID const &)
 
void resetLimiters ()
 
void resetMsgCounters ()
 
virtual void fillPrefix (std::ostringstream &, mf::ErrorObj const &msg)
 
virtual void fillUsrMsg (std::ostringstream &, mf::ErrorObj const &msg)
 
virtual void fillSuffix (std::ostringstream &, mf::ErrorObj const &msg)
 
virtual void flush ()
 

Protected Attributes

ELseverityLevel threshold_
 
MsgFormatSettings format_
 
int defaultLimit_
 
int defaultReportEvery_
 
int defaultTimespan_
 
std::map< std::string const, CategoryParamscategoryParams_
 
std::map< ELextendedID const, XidLimiterxidLimiters_
 
std::map< ELextendedID const, StatsCountstatsMap_
 
bool outputStatistics_ {false}
 
bool updatedStats_ {false}
 
bool reset_ {false}
 

Private Member Functions

void routePayload (std::ostringstream const &oss, ErrorObj const &msg) override
 

Private Attributes

cet::ostream_handle osh
 
ELextendedID xid {}
 

Detailed Description

Definition at line 13 of file ELostreamOutput.h.

Member Typedef Documentation

Member Enumeration Documentation

Constructor & Destructor Documentation

mf::service::ELostreamOutput::~ELostreamOutput ( )
default
mf::service::ELostreamOutput::ELostreamOutput ( Parameters const &  config,
cet::ostream_handle &&  h,
bool  emitAtStart = false 
)

Definition at line 15 of file ELostreamOutput.cc.

18  : ELostreamOutput{ps(), std::move(h), emitAtStart}
19  {}
ELostreamOutput(Parameters const &config, cet::ostream_handle &&, bool emitAtStart=false)
mf::service::ELostreamOutput::ELostreamOutput ( Parameters const &  config,
std::ostream &  os,
bool  emitAtStart = false 
)

Definition at line 9 of file ELostreamOutput.cc.

12  : ELostreamOutput{ps, cet::ostream_handle{os}, emitAtStart}
13  {}
ELostreamOutput(Parameters const &config, cet::ostream_handle &&, bool emitAtStart=false)
mf::service::ELostreamOutput::ELostreamOutput ( Config const &  config,
cet::ostream_handle &&  h,
bool  emitAtStart = false 
)

Definition at line 21 of file ELostreamOutput.cc.

References mf::service::ELostreamOutput::Config::elDestConfig, mf::service::ELdestination::emitToken(), and osh.

24  : ELdestination{config.elDestConfig()}, osh{std::move(h)}
25  {
26  if (emitAtStart) {
27  emitToken(
28  osh, "\n=================================================", true, true);
29  emitToken(osh,
30  "\nMessage Log File written by MessageLogger service\n",
31  false,
32  true);
33  emitToken(osh,
34  "\n=================================================\n",
35  true,
36  true);
37  }
38  }
void emitToken(std::ostream &os, std::string const &s, bool nl=false, bool preambleMode=false)
ELdestination(Config const &)
mf::service::ELostreamOutput::ELostreamOutput ( ELostreamOutput const &  )
delete
mf::service::ELostreamOutput::ELostreamOutput ( ELostreamOutput &&  )
delete

Member Function Documentation

void mf::service::ELdestination::emitToken ( std::ostream &  os,
std::string const &  s,
bool  nl = false,
bool  preambleMode = false 
)
protectedinherited

Definition at line 390 of file ELdestination.cc.

References mf::service::ELdestination::charsOnLine_, mf::service::ELdestination::format_, art::detail::indent(), and mf::service::ELdestination::MsgFormatSettings::lineLength.

Referenced by ELostreamOutput(), mf::service::ELdestination::fillPrefix(), mf::service::ELdestination::fillSuffix(), and mf::service::ELdestination::fillUsrMsg().

394  {
395  string const indent(6, ' ');
396  if (s.empty()) {
397  if (nl) {
398  os << '\n';
399  charsOnLine_ = 0UL;
400  }
401  return;
402  }
403  if (!preambleMode) {
404  os << s;
405  return;
406  }
407  char const first = s[0];
408  char const second = (s.length() < 2) ? '\0' : s[1];
409  char const last = (s.length() < 2) ? '\0' : s[s.length() - 1];
410  char const last2 = (s.length() < 3) ? '\0' : s[s.length() - 2];
411  // checking -2 because the very last char is sometimes a ' '
412  // inserted by ErrorLog::operator<<
413  // Accounts for newline @ the beginning of the string
414  if (first == '\n' || (charsOnLine_ + s.length()) > format_.lineLength) {
415  charsOnLine_ = 0UL;
416  if (second != ' ') {
417  os << ' ';
418  ++charsOnLine_;
419  }
420  if (first == '\n') {
421  os << s.substr(1);
422  } else {
423  os << s;
424  }
425  } else {
426  os << s;
427  }
428  if ((last == '\n') || (last2 == '\n')) {
429  os << indent;
430  if (last != ' ') {
431  os << ' ';
432  }
433  charsOnLine_ = indent.length() + 1UL;
434  }
435  if (nl) {
436  os << '\n';
437  charsOnLine_ = 0UL;
438  } else {
439  charsOnLine_ += s.length();
440  }
441  }
std::string indent(std::size_t const i)
MsgFormatSettings format_
second_as<> second
Type of time stored in seconds, in double precision.
Definition: spacetime.h:82
std::string nl(std::size_t i=1)
void mf::service::ELdestination::fillPrefix ( std::ostringstream &  oss,
mf::ErrorObj const &  msg 
)
protectedvirtualinherited

Reimplemented in mfplugins::ELsyslog.

Definition at line 444 of file ELdestination.cc.

References mf::service::ELdestination::charsOnLine_, mf::ErrorObj::context(), mf::service::ELdestination::emitToken(), mf::service::ELdestination::EPILOGUE_SEPARATE, mf::service::ELdestination::format_, mf::ErrorObj::idOverflow(), mf::ErrorObj::is_verbatim(), mf::service::ELdestination::MODULE, mf::ErrorObj::serial(), mf::service::ELdestination::SERIAL, mf::service::ELdestination::SOME_CONTEXT, mf::service::ELdestination::SUBROUTINE, mf::service::ELdestination::TIME_SEPARATE, mf::service::ELdestination::TIMESTAMP, mf::ErrorObj::timestamp(), mf::service::ELdestination::MsgFormatSettings::timestamp(), mf::service::ELdestination::MsgFormatSettings::want(), and mf::ErrorObj::xid().

Referenced by mf::service::ELdestination::log().

445  {
446  if (msg.is_verbatim()) {
447  return;
448  }
449  auto const& xid = msg.xid();
450  charsOnLine_ = 0UL;
451  emitToken(oss, "%MSG"s, false, true);
452  emitToken(oss, xid.severity().getSymbol(), false, true);
453  emitToken(oss, " ", false, true);
454  emitToken(oss, xid.id(), false, true);
455  emitToken(oss, msg.idOverflow(), false, true);
456  emitToken(oss, ": ", false, true);
457  if (format_.want(SERIAL)) {
458  ostringstream s;
459  s << msg.serial();
460  emitToken(oss, "[serial #" + s.str() + "] ", false, true);
461  }
462  bool needAspace = true;
464  if (xid.module().length() + xid.subroutine().length() > 0) {
465  emitToken(oss, "\n", false, true);
466  needAspace = false;
467  } else if (format_.want(TIMESTAMP) && !format_.want(TIME_SEPARATE)) {
468  emitToken(oss, "\n", false, true);
469  needAspace = false;
470  }
471  }
472  if (format_.want(MODULE) && (xid.module().length() > 0)) {
473  if (needAspace) {
474  emitToken(oss, " ", false, true);
475  needAspace = false;
476  }
477  emitToken(oss, xid.module() + " ", false, true);
478  }
479  if (format_.want(SUBROUTINE) && (xid.subroutine().length() > 0)) {
480  if (needAspace) {
481  emitToken(oss, " ", false, true);
482  needAspace = false;
483  }
484  emitToken(oss, xid.subroutine() + "() ", false, true);
485  }
486  if (format_.want(TIMESTAMP)) {
487  if (format_.want(TIME_SEPARATE)) {
488  emitToken(oss, "\n", false, true);
489  needAspace = false;
490  }
491  if (needAspace) {
492  emitToken(oss, " ", false, true);
493  needAspace = false;
494  }
495  emitToken(oss, format_.timestamp(msg.timestamp()) + " ", false, true);
496  }
497  if (format_.want(SOME_CONTEXT)) {
498  if (needAspace) {
499  emitToken(oss, " ", false, true);
500  needAspace = false;
501  }
502  emitToken(oss, msg.context(), false, true);
503  }
504  }
void emitToken(std::ostream &os, std::string const &s, bool nl=false, bool preambleMode=false)
MsgFormatSettings format_
void mf::service::ELdestination::fillSuffix ( std::ostringstream &  oss,
mf::ErrorObj const &  msg 
)
protectedvirtualinherited

Reimplemented in mfplugins::ELsyslog.

Definition at line 534 of file ELdestination.cc.

References mf::service::ELdestination::emitToken(), mf::service::ELdestination::format_, mf::ErrorObj::is_verbatim(), mf::service::ELdestination::NO_LINE_BREAKS, and mf::service::ELdestination::MsgFormatSettings::want().

Referenced by mf::service::ELdestination::log().

535  {
536  if (!msg.is_verbatim() && !format_.want(NO_LINE_BREAKS)) {
537  emitToken(oss, "\n%MSG");
538  }
539  oss << '\n';
540  }
void emitToken(std::ostream &os, std::string const &s, bool nl=false, bool preambleMode=false)
MsgFormatSettings format_
void mf::service::ELdestination::fillUsrMsg ( std::ostringstream &  oss,
mf::ErrorObj const &  msg 
)
protectedvirtualinherited

Reimplemented in mfplugins::ELsyslog.

Definition at line 507 of file ELdestination.cc.

References mf::service::ELdestination::emitToken(), mf::ErrorObj::filename(), mf::service::ELdestination::format_, mf::ErrorObj::is_verbatim(), mf::ErrorObj::items(), mf::ErrorObj::lineNumber(), mf::service::ELdestination::NO_LINE_BREAKS, mf::service::ELdestination::TEXT, util::to_string(), and mf::service::ELdestination::MsgFormatSettings::want().

Referenced by mfplugins::ELsyslog::fillUsrMsg(), and mf::service::ELdestination::log().

508  {
509  if (!format_.want(TEXT)) {
510  return;
511  }
512  // Determine if file and line should be included
513  if (!msg.is_verbatim()) {
514  if (!msg.filename().empty()) {
515  emitToken(oss, " "s);
516  emitToken(oss, msg.filename());
517  emitToken(oss, ":"s);
518  emitToken(oss, to_string(msg.lineNumber()));
519  }
520  // Check for user-requested line breaks
521  if (format_.want(NO_LINE_BREAKS)) {
522  emitToken(oss, " ==> ");
523  } else {
524  emitToken(oss, "", true);
525  }
526  }
527  // Print the contents.
528  for (auto const& val : msg.items()) {
529  emitToken(oss, val);
530  }
531  }
void emitToken(std::ostream &os, std::string const &s, bool nl=false, bool preambleMode=false)
decltype(auto) constexpr to_string(T &&obj)
ADL-aware version of std::to_string.
MsgFormatSettings format_
void mf::service::ELdestination::finish ( )
virtualinherited

Definition at line 703 of file ELdestination.cc.

704  {}
void mf::service::ELdestination::flush ( )
protectedvirtualinherited

Definition at line 715 of file ELdestination.cc.

References mf::ELwarning, and mf::service::ELdestination::log().

716  {
717  ErrorObj msg{ELwarning, "ELdestination"s};
718  msg << "Call to unimplemented flush()!";
719  log(msg);
720  }
virtual void log(mf::ErrorObj &)
ELslProxy< ELwarningGen > constexpr ELwarning
string mf::service::ELdestination::formSummary ( )
protectedinherited

Definition at line 576 of file ELdestination.cc.

References art::left(), n, mf::ELseverityLevel::nLevels, art::right(), and mf::service::ELdestination::statsMap_.

Referenced by mf::service::ELstatistics::summary(), and mf::service::ELdestination::summary().

577  {
578  ostringstream s;
579  int n{};
580  // ----- Summary part I:
581  //
582  bool ftnote{false};
583  struct part3 {
584  long n{}, t{};
586  for (auto const& [xid, count] : statsMap_) {
587  auto const& cat = xid.id();
588  // ----- Emit new part I header, if needed:
589  //
590  if (n == 0) {
591  s << "\n";
592  s << " type category sev module subroutine "
593  " count total\n"
594  << " ---- -------------------- -- ---------------- "
595  "---------------- ----- -----\n";
596  }
597  // ----- Emit detailed message information:
598  //
599  s
600  // Type
601  << right << setw(5) << ++n
602  << ' '
603  // Category
604  << left << setw(20) << cat.substr(0, 20)
605  << ' '
606  // Severity
607  << left << setw(2) << xid.severity().getSymbol()
608  << ' '
609  // Module
610  << left << setw(16) << xid.module().substr(0, 16)
611  << ' '
612  // Subroutine
613  << left << setw(16)
614  << xid.subroutine().substr(0, 16)
615  // Count
616  << right << setw(7) << count.n_ << left << setw(1)
617  << (count.ignoredFlag_ ? '*' : ' ')
618  // Total Count
619  << right << setw(8) << count.aggregateN_ << '\n';
620  ftnote = ftnote || count.ignoredFlag_;
621  // ----- Obtain information for Part III, below:
622  //
623  p3[xid.severity().getLevel()].n += count.n_;
624  p3[xid.severity().getLevel()].t += count.aggregateN_;
625  }
626  // ----- Provide footnote to part I, if needed:
627  //
628  if (ftnote) {
629  s << "\n* Some occurrences of this message were suppressed in all "
630  "logs, due to limits.\n";
631  }
632  // ----- Summary part II:
633  //
634  n = 0;
635  for (auto const& pr : statsMap_) {
636  auto const& xid = pr.first;
637  auto const& count = pr.second;
638  string const& cat = xid.id();
639  if (n == 0) {
640  s << '\n'
641  << " type category Examples: run/evt run/evt "
642  "run/evt\n"
643  << " ---- -------------------- ---------------- ---------------- "
644  "----------------\n";
645  }
646  s
647  // Type
648  << right << setw(5) << ++n
649  << ' '
650  // Category
651  << left << setw(20) << cat
652  << ' '
653  // Context1
654  << left << setw(16) << count.context1_.c_str()
655  << ' '
656  // Context2
657  << left << setw(16) << count.context2_.c_str()
658  << ' '
659  // ContextLast
660  << count.contextLast_ << '\n';
661  }
662  // ----- Summary part III:
663  //
664  s << '\n'
665  << "Severity # Occurrences Total Occurrences\n"
666  << "-------- ------------- -----------------\n";
667  for (int k = 0; k < ELseverityLevel::nLevels; ++k) {
668  if (p3[k].n != 0 || p3[k].t != 0) {
669  s
670  // Severity
671  << left << setw(8)
672  << ELseverityLevel{ELseverityLevel::ELsev_(k)}.getName().c_str()
673  // Occurrences
674  << right << setw(17)
675  << p3[k].n
676  // Total Occurrences
677  << right << setw(20) << p3[k].t << '\n';
678  }
679  }
680  return s.str();
681  }
constexpr auto const & right(const_AssnsIter< L, R, D, Dir > const &a, const_AssnsIter< L, R, D, Dir > const &b)
Definition: AssnsIter.h:102
std::map< ELextendedID const, StatsCount > statsMap_
constexpr auto const & left(const_AssnsIter< L, R, D, Dir > const &a, const_AssnsIter< L, R, D, Dir > const &b)
Definition: AssnsIter.h:94
Char_t n[5]
void mf::service::ELdestination::log ( mf::ErrorObj msg)
virtualinherited

Reimplemented in mf::service::ELstatistics.

Definition at line 547 of file ELdestination.cc.

References mf::ErrorObj::context(), mf::service::ELdestination::fillPrefix(), mf::service::ELdestination::fillSuffix(), mf::service::ELdestination::fillUsrMsg(), mf::service::ELdestination::outputStatistics_, mf::service::ELdestination::routePayload(), mf::ErrorObj::setReactedTo(), mf::ELextendedID::severity(), mf::service::ELdestination::skipMsg(), mf::service::ELdestination::statsMap_, mf::service::ELdestination::summarizeContext(), mf::service::ELdestination::threshold_, mf::service::ELdestination::updatedStats_, and mf::ErrorObj::xid().

Referenced by mf::service::ELdestination::flush().

548  {
549  if (msg.xid().severity() < threshold_) {
550  if (outputStatistics_) {
551  statsMap_[msg.xid()].add(summarizeContext(msg.context()), false);
552  updatedStats_ = true;
553  }
554  return;
555  }
556  if (skipMsg(msg.xid())) {
557  if (outputStatistics_) {
558  statsMap_[msg.xid()].add(summarizeContext(msg.context()), false);
559  updatedStats_ = true;
560  }
561  return;
562  }
563  msg.setReactedTo(true);
564  ostringstream payload;
565  fillPrefix(payload, msg);
566  fillUsrMsg(payload, msg);
567  fillSuffix(payload, msg);
568  routePayload(payload, msg);
569  if (outputStatistics_) {
570  statsMap_[msg.xid()].add(summarizeContext(msg.context()), true);
571  updatedStats_ = true;
572  }
573  }
ELseverityLevel severity() const
Definition: ELextendedID.cc:33
virtual void fillUsrMsg(std::ostringstream &, mf::ErrorObj const &msg)
bool skipMsg(ELextendedID const &)
virtual void fillSuffix(std::ostringstream &, mf::ErrorObj const &msg)
std::string const & context() const
Definition: ErrorObj.cc:98
std::map< ELextendedID const, StatsCount > statsMap_
std::string summarizeContext(std::string const &)
ELextendedID const & xid() const
Definition: ErrorObj.cc:61
ELseverityLevel threshold_
virtual void fillPrefix(std::ostringstream &, mf::ErrorObj const &msg)
virtual void setReactedTo(bool)
Definition: ErrorObj.cc:177
virtual void routePayload(std::ostringstream const &, mf::ErrorObj const &msg)
ELostreamOutput& mf::service::ELostreamOutput::operator= ( ELostreamOutput const &  )
delete
ELostreamOutput& mf::service::ELostreamOutput::operator= ( ELostreamOutput &&  )
delete
void mf::service::ELdestination::resetLimiters ( )
protectedinherited

Definition at line 819 of file ELdestination.cc.

References mf::service::ELdestination::xidLimiters_.

Referenced by mf::service::ELstatistics::summary(), and mf::service::ELdestination::summary().

820  {
821  xidLimiters_.clear();
822  }
std::map< ELextendedID const, XidLimiter > xidLimiters_
void mf::service::ELdestination::resetMsgCounters ( )
protectedinherited

Definition at line 813 of file ELdestination.cc.

References mf::service::ELdestination::statsMap_.

Referenced by mf::service::ELstatistics::summary(), and mf::service::ELdestination::summary().

814  {
815  statsMap_.clear();
816  }
std::map< ELextendedID const, StatsCount > statsMap_
void mf::service::ELostreamOutput::routePayload ( std::ostringstream const &  oss,
mf::ErrorObj const &  msg 
)
overrideprivatevirtual

Reimplemented from mf::service::ELdestination.

Definition at line 41 of file ELostreamOutput.cc.

References osh.

42  {
43  osh << oss.str();
44  osh.flush();
45  }
void mf::service::ELdestination::setThreshold ( ELseverityLevel  sv)
inherited

Definition at line 709 of file ELdestination.cc.

References mf::service::ELdestination::threshold_.

710  {
711  threshold_ = sv;
712  }
ELseverityLevel threshold_
bool mf::service::ELdestination::skipMsg ( ELextendedID const &  xid)
protectedinherited

Definition at line 726 of file ELdestination.cc.

References mf::service::ELdestination::categoryParams_, mf::service::ELdestination::defaultLimit_, mf::service::ELdestination::defaultReportEvery_, mf::service::ELdestination::defaultTimespan_, mf::ELextendedID::id(), mf::service::ELdestination::XidLimiter::limit_, mf::service::ELdestination::XidLimiter::msgCount_, mf::service::ELdestination::XidLimiter::previousTimestamp_, r, mf::service::ELdestination::XidLimiter::reportEvery_, mf::service::ELdestination::XidLimiter::skippedMsgCount_, mf::service::ELdestination::XidLimiter::timespan_, and mf::service::ELdestination::xidLimiters_.

Referenced by mf::service::ELstatistics::log(), and mf::service::ELdestination::log().

727  {
728  auto xl_iter = xidLimiters_.find(xid);
729  if (xl_iter == xidLimiters_.end()) {
730  // Need to create and initialize a limiter for this xid.
731  int limit{defaultLimit_};
732  int reportEvery{defaultReportEvery_};
733  int timespan{defaultTimespan_};
734  // Does the category of this xid have explicit limits?
735  auto cp_iter = categoryParams_.find(xid.id());
736  if (cp_iter != categoryParams_.end()) {
737  // Category limits found, use them.
738  auto const& cp = cp_iter->second;
739  limit = (cp.limit_ < 0) ? defaultLimit_ : cp.limit_;
740  reportEvery =
741  (cp.reportEvery_ < 0) ? defaultReportEvery_ : cp.reportEvery_;
742  timespan = (cp.timespan_ < 0) ? defaultTimespan_ : cp.timespan_;
743  }
744  XidLimiter& limiter = xidLimiters_[xid];
745  limiter.previousTimestamp_ = time(0);
746  limiter.msgCount_ = 0;
747  limiter.skippedMsgCount_ =
748  reportEvery - 1; // So that the FIRST of the prescaled messages emerges
749  limiter.limit_ = limit;
750  limiter.reportEvery_ = reportEvery;
751  limiter.timespan_ = timespan;
752  xl_iter = xidLimiters_.find(xid);
753  }
754  XidLimiter& limiter = xl_iter->second;
755  time_t now = time(0);
756  // Has it been so long that we should restart counting toward the limit?
757  if ((limiter.timespan_ >= 0) &&
758  (difftime(now, limiter.previousTimestamp_) >= limiter.timespan_)) {
759  limiter.msgCount_ = 0;
760  if (limiter.reportEvery_ > 0) {
761  // So this message will be reacted to
762  limiter.skippedMsgCount_ = limiter.reportEvery_ - 1;
763  } else {
764  limiter.skippedMsgCount_ = 0;
765  }
766  }
767  limiter.previousTimestamp_ = now;
768  ++limiter.msgCount_;
769  ++limiter.skippedMsgCount_;
770  if (limiter.skippedMsgCount_ < limiter.reportEvery_) {
771  // Skip message.
772  return true;
773  }
774  if (limiter.limit_ == 0) {
775  // Zero limit - never react to this
776  // Skip message.
777  return true;
778  }
779  if ((limiter.limit_ < 0) || (limiter.msgCount_ <= limiter.limit_)) {
780  limiter.skippedMsgCount_ = 0;
781  // Accept message.
782  return false;
783  }
784  // Now we are over the limit - have we exceeded limit by 2^N * limit?
785  long diff = limiter.msgCount_ - limiter.limit_;
786  long r = diff / limiter.limit_;
787  if (r * limiter.limit_ != diff) {
788  // Not a multiple of limit - don't react
789  // Skip message.
790  return true;
791  }
792  if (r == 1) {
793  // Exactly twice limit - react
794  limiter.skippedMsgCount_ = 0;
795  // Accept message.
796  return false;
797  }
798  while (r > 1) {
799  if ((r & 1) != 0) {
800  // Not 2**msgCount_ times limit - don't react
801  // Skip message.
802  return true;
803  }
804  r >>= 1;
805  }
806  // If you never get an odd number till one, r is 2**msgCount_ so react
807  limiter.skippedMsgCount_ = 0;
808  // Accept message.
809  return false;
810  }
TRandom r
Definition: spectrum.C:23
std::map< std::string const, CategoryParams > categoryParams_
std::map< ELextendedID const, XidLimiter > xidLimiters_
string mf::service::ELdestination::summarizeContext ( std::string const &  )
protectedinherited

Definition at line 360 of file ELdestination.cc.

Referenced by mf::service::ELstatistics::log(), and mf::service::ELdestination::log().

361  {
362  if (c.substr(0, 4) != "Run:") {
363  return c;
364  }
365  istringstream is(c);
366  string runWord;
367  int run;
368  is >> runWord >> run;
369  if (!is) {
370  return c;
371  }
372  if (runWord != "Run:") {
373  return c;
374  }
375  string eventWord;
376  int event;
377  is >> eventWord >> event;
378  if (!is) {
379  return c;
380  }
381  if (eventWord != "Event:") {
382  return c;
383  }
384  ostringstream os;
385  os << run << "/" << event;
386  return os.str();
387  }
Event finding and building.
void mf::service::ELdestination::summary ( )
virtualinherited

Reimplemented in mf::service::ELstatistics.

Definition at line 686 of file ELdestination.cc.

References mf::ELzeroSeverity, mf::service::ELdestination::formSummary(), mf::service::ELdestination::outputStatistics_, mf::service::ELdestination::reset_, mf::service::ELdestination::resetLimiters(), mf::service::ELdestination::resetMsgCounters(), mf::service::ELdestination::routePayload(), and mf::service::ELdestination::updatedStats_.

687  {
689  ostringstream payload;
690  payload << "\n=============================================\n\n"
691  << "MessageLogger Summary\n"
692  << formSummary();
693  routePayload(payload, ErrorObj{ELzeroSeverity, "No ostream"s});
694  }
695  updatedStats_ = false;
696  if (reset_) {
698  resetLimiters();
699  }
700  }
ELslProxy< ELzeroSeverityGen > constexpr ELzeroSeverity
virtual void routePayload(std::ostringstream const &, mf::ErrorObj const &msg)

Member Data Documentation

std::map<std::string const, CategoryParams> mf::service::ELdestination::categoryParams_
protectedinherited
int mf::service::ELdestination::defaultLimit_
protectedinherited
int mf::service::ELdestination::defaultReportEvery_
protectedinherited
int mf::service::ELdestination::defaultTimespan_
protectedinherited
cet::ostream_handle mf::service::ELostreamOutput::osh
private

Definition at line 39 of file ELostreamOutput.h.

Referenced by ELostreamOutput(), and routePayload().

bool mf::service::ELdestination::outputStatistics_ {false}
protectedinherited
bool mf::service::ELdestination::reset_ {false}
protectedinherited
ELseverityLevel mf::service::ELdestination::threshold_
protectedinherited
bool mf::service::ELdestination::updatedStats_ {false}
protectedinherited
ELextendedID mf::service::ELostreamOutput::xid {}
private

Definition at line 40 of file ELostreamOutput.h.

std::map<ELextendedID const, XidLimiter> mf::service::ELdestination::xidLimiters_
protectedinherited

The documentation for this class was generated from the following files: