LArSoft  v07_13_02
Liquid Argon Software toolkit - http://larsoft.org/
mf::service::ELdestination::MsgFormatSettings Class Reference

#include "ELdestination.h"

Classes

struct  Config
 

Public Member Functions

 ~MsgFormatSettings ()
 
 MsgFormatSettings (Config const &config)
 
bool want (flag_enum const) const
 
std::string timestamp (timeval const &)
 

Public Attributes

std::bitset< NFLAGSflags
 
std::size_t lineLength
 

Private Attributes

int timeMethod_ {0}
 
std::string timeFmt_ {}
 

Detailed Description

Definition at line 104 of file ELdestination.h.

Constructor & Destructor Documentation

mf::service::ELdestination::MsgFormatSettings::~MsgFormatSettings ( )

Definition at line 140 of file ELdestination.cc.

140 {}
mf::service::ELdestination::MsgFormatSettings::MsgFormatSettings ( Config const &  config)

Definition at line 142 of file ELdestination.cc.

References mf::service::ELdestination::EPILOGUE_SEPARATE, flags, mf::service::ELdestination::FULL_CONTEXT, lineLength, mf::service::ELdestination::MODULE, mf::service::ELdestination::NO_LINE_BREAKS, s, mf::service::ELdestination::SERIAL, mf::service::ELdestination::SOME_CONTEXT, mf::service::ELdestination::SUBROUTINE, mf::service::ELdestination::TEXT, mf::service::ELdestination::TIME_SEPARATE, timeFmt_, timeMethod_, mf::service::ELdestination::TIMESTAMP, and fhicl::detail::atom::value().

143  : timeMethod_{0}, timeFmt_{}
144  {
145  auto const& value = config.timestamp();
146  bool const use_timestamp = (value != "none"s);
147  flags.set(TIMESTAMP, use_timestamp);
148  if (!use_timestamp) {
149  timeMethod_ = 0;
150  } else if (value == "default"s) {
151  timeMethod_ = 1;
152  timeFmt_ = "%d-%b-%Y %H:%M:%S %Z"s;
153  } else if (value == "default_ms"s) {
154  timeMethod_ = 2;
155  timeFmt_ = "%d-%b-%Y %H:%M:%S.%%03u %Z"s;
156  } else {
157  timeMethod_ = 1;
158  timeFmt_ = value;
159  }
160  lineLength = config.noLineBreaks() ? 32000ull : config.lineLength();
161  flags.set(NO_LINE_BREAKS, config.noLineBreaks());
162  flags.set(MODULE, config.wantModule());
163  flags.set(SUBROUTINE, config.wantSubroutine());
164  flags.set(TEXT, config.wantText());
165  flags.set(SOME_CONTEXT, config.wantSomeContext());
166  flags.set(SERIAL, config.wantSerial());
167  flags.set(FULL_CONTEXT, config.wantFullContext());
168  flags.set(TIME_SEPARATE, config.wantTimeSeparate());
169  flags.set(EPILOGUE_SEPARATE, config.wantEpilogueSeparate());
170  }
Float_t s
Definition: plot.C:23
std::string value(boost::any const &)

Member Function Documentation

string mf::service::ELdestination::MsgFormatSettings::timestamp ( timeval const &  t)

Definition at line 179 of file ELdestination.cc.

References timeFmt_, and timeMethod_.

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

180  {
181  size_t constexpr SIZE{144};
182  string ret;
183  if (timeMethod_ == 0) {
184  return ret;
185  }
186  struct tm timebuf;
187  char ts[SIZE];
188  if (timeMethod_ == 1) {
189  strftime(
190  ts, sizeof(ts), timeFmt_.data(), localtime_r(&t.tv_sec, &timebuf));
191  ret = ts;
192  return ret;
193  }
194  char tmpts[SIZE];
195  strftime(tmpts,
196  sizeof(tmpts),
197  timeFmt_.data(),
198  localtime_r(&t.tv_sec, &timebuf));
199  snprintf(ts, sizeof(ts), tmpts, static_cast<unsigned>(t.tv_usec / 1000));
200  ret = ts;
201  return ret;
202  }
bool mf::service::ELdestination::MsgFormatSettings::want ( flag_enum const  FLAG) const

Definition at line 173 of file ELdestination.cc.

References flags.

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

174  {
175  return flags.test(FLAG);
176  }

Member Data Documentation

std::bitset<NFLAGS> mf::service::ELdestination::MsgFormatSettings::flags

Definition at line 138 of file ELdestination.h.

Referenced by MsgFormatSettings(), and want().

std::size_t mf::service::ELdestination::MsgFormatSettings::lineLength

Definition at line 139 of file ELdestination.h.

Referenced by mf::service::ELdestination::emitToken(), and MsgFormatSettings().

std::string mf::service::ELdestination::MsgFormatSettings::timeFmt_ {}
private

Definition at line 144 of file ELdestination.h.

Referenced by MsgFormatSettings(), and timestamp().

int mf::service::ELdestination::MsgFormatSettings::timeMethod_ {0}
private

Definition at line 143 of file ELdestination.h.

Referenced by MsgFormatSettings(), and timestamp().


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