LArSoft  v07_13_02
Liquid Argon Software toolkit - http://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, mf::ErrorObj const &msg) override
 

Private Attributes

cet::ostream_handle osh
 
mf::ELextendedID xid {}
 

Detailed Description

Definition at line 24 of file ELostreamOutput.h.

Member Typedef Documentation

Member Enumeration Documentation

Constructor & Destructor Documentation

mf::service::ELostreamOutput::~ELostreamOutput ( )

Definition at line 17 of file ELostreamOutput.cc.

17 {}
mf::service::ELostreamOutput::ELostreamOutput ( Parameters const &  config,
cet::ostream_handle &&  h,
bool  emitAtStart = false 
)

Definition at line 25 of file ELostreamOutput.cc.

28  : ELostreamOutput{ps(), move(h), emitAtStart}
29  {}
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 19 of file ELostreamOutput.cc.

22  : ELostreamOutput{ps, cet::ostream_handle{os}, emitAtStart}
23  {}
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 31 of file ELostreamOutput.cc.

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

34  : ELdestination{config.elDestConfig()}, osh{move(h)}
35  {
36  if (emitAtStart) {
37  emitToken(osh,
38  "\n=================================================",
39  true,
40  true);
41  emitToken(osh,
42  "\nMessage Log File written by MessageLogger service\n",
43  false,
44  true);
45  emitToken(osh,
46  "\n=================================================\n",
47  true,
48  true);
49  }
50  }
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 408 of file ELdestination.cc.

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

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

412  {
413  string indent(6, ' ');
414  if (s.empty()) {
415  if (nl) {
416  os << '\n';
417  charsOnLine_ = 0UL;
418  }
419  return;
420  }
421  if (!preambleMode) {
422  os << s;
423  return;
424  }
425  char const first = s[0];
426  char const second = (s.length() < 2) ? '\0' : s[1];
427  char const last = (s.length() < 2) ? '\0' : s[s.length() - 1];
428  char const last2 = (s.length() < 3) ? '\0' : s[s.length() - 2];
429  // checking -2 because the very last char is sometimes a ' '
430  // inserted by ErrorLog::operator<<
431  // Accounts for newline @ the beginning of the string
432  if (first == '\n' || (charsOnLine_ + s.length()) > format_.lineLength) {
433  charsOnLine_ = 0UL;
434  if (second != ' ') {
435  os << ' ';
436  ++charsOnLine_;
437  }
438  if (first == '\n') {
439  os << s.substr(1);
440  } else {
441  os << s;
442  }
443  } else {
444  os << s;
445  }
446  if ((last == '\n') || (last2 == '\n')) {
447  os << indent;
448  if (last != ' ') {
449  os << ' ';
450  }
451  charsOnLine_ = indent.length() + 1UL;
452  }
453  if (nl) {
454  os << '\n';
455  charsOnLine_ = 0UL;
456  } else {
457  charsOnLine_ += s.length();
458  }
459  }
Float_t s
Definition: plot.C:23
std::string indent(std::size_t const i)
MsgFormatSettings format_
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 462 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, s, 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().

463  {
464  if (msg.is_verbatim()) {
465  return;
466  }
467  auto const& xid = msg.xid();
468  charsOnLine_ = 0UL;
469  emitToken(oss, "%MSG"s, false, true);
470  emitToken(oss, xid.severity().getSymbol(), false, true);
471  emitToken(oss, " ", false, true);
472  emitToken(oss, xid.id(), false, true);
473  emitToken(oss, msg.idOverflow(), false, true);
474  emitToken(oss, ": ", false, true);
475  if (format_.want(SERIAL)) {
476  ostringstream s;
477  s << msg.serial();
478  emitToken(oss, "[serial #" + s.str() + "] ", false, true);
479  }
480  bool needAspace = true;
482  if (xid.module().length() + xid.subroutine().length() > 0) {
483  emitToken(oss, "\n", false, true);
484  needAspace = false;
485  } else if (format_.want(TIMESTAMP) && !format_.want(TIME_SEPARATE)) {
486  emitToken(oss, "\n", false, true);
487  needAspace = false;
488  }
489  }
490  if (format_.want(MODULE) && (xid.module().length() > 0)) {
491  if (needAspace) {
492  emitToken(oss, " ", false, true);
493  needAspace = false;
494  }
495  emitToken(oss, xid.module() + " ", false, true);
496  }
497  if (format_.want(SUBROUTINE) && (xid.subroutine().length() > 0)) {
498  if (needAspace) {
499  emitToken(oss, " ", false, true);
500  needAspace = false;
501  }
502  emitToken(oss, xid.subroutine() + "() ", false, true);
503  }
504  if (format_.want(TIMESTAMP)) {
505  if (format_.want(TIME_SEPARATE)) {
506  emitToken(oss, "\n", false, true);
507  needAspace = false;
508  }
509  if (needAspace) {
510  emitToken(oss, " ", false, true);
511  needAspace = false;
512  }
513  emitToken(oss, format_.timestamp(msg.timestamp()) + " ", false, true);
514  }
515  if (format_.want(SOME_CONTEXT)) {
516  if (needAspace) {
517  emitToken(oss, " ", false, true);
518  needAspace = false;
519  }
520  emitToken(oss, msg.context(), false, true);
521  }
522  }
Float_t s
Definition: plot.C:23
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 552 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().

553  {
554  if (!msg.is_verbatim() && !format_.want(NO_LINE_BREAKS)) {
555  emitToken(oss, "\n%MSG");
556  }
557  oss << '\n';
558  }
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 525 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, s, mf::service::ELdestination::TEXT, util::flags::to_string(), and mf::service::ELdestination::MsgFormatSettings::want().

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

526  {
527  if (!format_.want(TEXT)) {
528  return;
529  }
530  // Determine if file and line should be included
531  if (!msg.is_verbatim()) {
532  if (!msg.filename().empty()) {
533  emitToken(oss, " "s);
534  emitToken(oss, msg.filename());
535  emitToken(oss, ":"s);
536  emitToken(oss, to_string(msg.lineNumber()));
537  }
538  // Check for user-requested line breaks
539  if (format_.want(NO_LINE_BREAKS)) {
540  emitToken(oss, " ==> ");
541  } else {
542  emitToken(oss, "", true);
543  }
544  }
545  // Print the contents.
546  for (auto const& val : msg.items()) {
547  emitToken(oss, val);
548  }
549  }
Float_t s
Definition: plot.C:23
void emitToken(std::ostream &os, std::string const &s, bool nl=false, bool preambleMode=false)
std::string to_string(Flag_t< Storage > const flag)
Convert a flag into a stream (shows its index).
Definition: BitMask.h:187
MsgFormatSettings format_
void mf::service::ELdestination::finish ( )
virtualinherited

Definition at line 723 of file ELdestination.cc.

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

Definition at line 735 of file ELdestination.cc.

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

736  {
737  ErrorObj msg{ELwarning, "ELdestination"s};
738  msg << "Call to unimplemented flush()!";
739  log(msg);
740  }
Float_t s
Definition: plot.C:23
virtual void log(mf::ErrorObj &)
ELslProxy< ELwarningGen > constexpr ELwarning
string mf::service::ELdestination::formSummary ( )
protectedinherited

Definition at line 594 of file ELdestination.cc.

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

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

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

Reimplemented in mf::service::ELstatistics.

Definition at line 565 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().

566  {
567  if (msg.xid().severity() < threshold_) {
568  if (outputStatistics_) {
569  statsMap_[msg.xid()].add(summarizeContext(msg.context()), false);
570  updatedStats_ = true;
571  }
572  return;
573  }
574  if (skipMsg(msg.xid())) {
575  if (outputStatistics_) {
576  statsMap_[msg.xid()].add(summarizeContext(msg.context()), false);
577  updatedStats_ = true;
578  }
579  return;
580  }
581  msg.setReactedTo(true);
582  ostringstream payload;
583  fillPrefix(payload, msg);
584  fillUsrMsg(payload, msg);
585  fillSuffix(payload, msg);
586  routePayload(payload, msg);
587  if (outputStatistics_) {
588  statsMap_[msg.xid()].add(summarizeContext(msg.context()), true);
589  updatedStats_ = true;
590  }
591  }
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 840 of file ELdestination.cc.

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

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

841  {
842  xidLimiters_.clear();
843  }
std::map< ELextendedID const, XidLimiter > xidLimiters_
void mf::service::ELdestination::resetMsgCounters ( )
protectedinherited

Definition at line 834 of file ELdestination.cc.

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

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

835  {
836  statsMap_.clear();
837  }
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 53 of file ELostreamOutput.cc.

References osh.

54  {
55  osh << oss.str();
56  osh.flush();
57  }
void mf::service::ELdestination::setThreshold ( ELseverityLevel  sv)
inherited

Definition at line 729 of file ELdestination.cc.

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

730  {
731  threshold_ = sv;
732  }
ELseverityLevel threshold_
bool mf::service::ELdestination::skipMsg ( ELextendedID const &  xid)
protectedinherited

Definition at line 746 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_, 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().

747  {
748  auto xl_iter = xidLimiters_.find(xid);
749  if (xl_iter == xidLimiters_.end()) {
750  // Need to create and initialize a limiter for this xid.
751  int limit{defaultLimit_};
752  int reportEvery{defaultReportEvery_};
753  int timespan{defaultTimespan_};
754  // Does the category of this xid have explicit limits?
755  auto cp_iter = categoryParams_.find(xid.id());
756  if (cp_iter != categoryParams_.end()) {
757  // Category limits found, use them.
758  auto const& cp = cp_iter->second;
759  limit = (cp.limit_ < 0) ? defaultLimit_ : cp.limit_;
760  reportEvery =
761  (cp.reportEvery_ < 0) ? defaultReportEvery_ : cp.reportEvery_;
762  timespan = (cp.timespan_ < 0) ? defaultTimespan_ : cp.timespan_;
763  }
764  XidLimiter& limiter = xidLimiters_[xid];
765  limiter.previousTimestamp_ = time(0);
766  limiter.msgCount_ = 0;
767  limiter.skippedMsgCount_ =
768  reportEvery -
769  1; // So that the FIRST of the prescaled messages emerges
770  limiter.limit_ = limit;
771  limiter.reportEvery_ = reportEvery;
772  limiter.timespan_ = timespan;
773  xl_iter = xidLimiters_.find(xid);
774  }
775  XidLimiter& limiter = xl_iter->second;
776  time_t now = time(0);
777  // Has it been so long that we should restart counting toward the limit?
778  if ((limiter.timespan_ >= 0) &&
779  (difftime(now, limiter.previousTimestamp_) >= limiter.timespan_)) {
780  limiter.msgCount_ = 0;
781  if (limiter.reportEvery_ > 0) {
782  // So this message will be reacted to
783  limiter.skippedMsgCount_ = limiter.reportEvery_ - 1;
784  } else {
785  limiter.skippedMsgCount_ = 0;
786  }
787  }
788  limiter.previousTimestamp_ = now;
789  ++limiter.msgCount_;
790  ++limiter.skippedMsgCount_;
791  if (limiter.skippedMsgCount_ < limiter.reportEvery_) {
792  // Skip message.
793  return true;
794  }
795  if (limiter.limit_ == 0) {
796  // Zero limit - never react to this
797  // Skip message.
798  return true;
799  }
800  if ((limiter.limit_ < 0) || (limiter.msgCount_ <= limiter.limit_)) {
801  limiter.skippedMsgCount_ = 0;
802  // Accept message.
803  return false;
804  }
805  // Now we are over the limit - have we exceeded limit by 2^N * limit?
806  long diff = limiter.msgCount_ - limiter.limit_;
807  long r = diff / limiter.limit_;
808  if (r * limiter.limit_ != diff) {
809  // Not a multiple of limit - don't react
810  // Skip message.
811  return true;
812  }
813  if (r == 1) {
814  // Exactly twice limit - react
815  limiter.skippedMsgCount_ = 0;
816  // Accept message.
817  return false;
818  }
819  while (r > 1) {
820  if ((r & 1) != 0) {
821  // Not 2**msgCount_ times limit - don't react
822  // Skip message.
823  return true;
824  }
825  r >>= 1;
826  }
827  // If you never get an odd number till one, r is 2**msgCount_ so react
828  limiter.skippedMsgCount_ = 0;
829  // Accept message.
830  return false;
831  }
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 378 of file ELdestination.cc.

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

379  {
380  if (c.substr(0, 4) != "Run:") {
381  return c;
382  }
383  istringstream is(c);
384  string runWord;
385  int run;
386  is >> runWord >> run;
387  if (!is) {
388  return c;
389  }
390  if (runWord != "Run:") {
391  return c;
392  }
393  string eventWord;
394  int event;
395  is >> eventWord >> event;
396  if (!is) {
397  return c;
398  }
399  if (eventWord != "Event:") {
400  return c;
401  }
402  ostringstream os;
403  os << run << "/" << event;
404  return os.str();
405  }
Event finding and building.
void mf::service::ELdestination::summary ( )
virtualinherited

Reimplemented in mf::service::ELstatistics.

Definition at line 706 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(), s, and mf::service::ELdestination::updatedStats_.

707  {
709  ostringstream payload;
710  payload << "\n=============================================\n\n"
711  << "MessageLogger Summary\n"
712  << formSummary();
713  routePayload(payload, ErrorObj{ELzeroSeverity, "No ostream"s});
714  }
715  updatedStats_ = false;
716  if (reset_) {
718  resetLimiters();
719  }
720  }
Float_t s
Definition: plot.C:23
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 54 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
mf::ELextendedID mf::service::ELostreamOutput::xid {}
private

Definition at line 55 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: