LArSoft  v09_90_00
Liquid Argon Software toolkit - https://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 95 of file ELdestination.h.

Constructor & Destructor Documentation

mf::service::ELdestination::MsgFormatSettings::~MsgFormatSettings ( )
default
mf::service::ELdestination::MsgFormatSettings::MsgFormatSettings ( Config const &  config)

Definition at line 132 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, 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 value.

133  : timeMethod_{0}, timeFmt_{}
134  {
135  auto const& value = config.timestamp();
136  bool const use_timestamp = (value != "none"s);
137  flags.set(TIMESTAMP, use_timestamp);
138  if (!use_timestamp) {
139  timeMethod_ = 0;
140  } else if (value == "default"s) {
141  timeMethod_ = 1;
142  timeFmt_ = "%d-%b-%Y %H:%M:%S %Z"s;
143  } else if (value == "default_ms"s) {
144  timeMethod_ = 2;
145  timeFmt_ = "%d-%b-%Y %H:%M:%S.%%03u %Z"s;
146  } else {
147  timeMethod_ = 1;
148  timeFmt_ = value;
149  }
150  lineLength = config.noLineBreaks() ? 32000ull : config.lineLength();
151  flags.set(NO_LINE_BREAKS, config.noLineBreaks());
152  flags.set(MODULE, config.wantModule());
153  flags.set(SUBROUTINE, config.wantSubroutine());
154  flags.set(TEXT, config.wantText());
155  flags.set(SOME_CONTEXT, config.wantSomeContext());
156  flags.set(SERIAL, config.wantSerial());
157  flags.set(FULL_CONTEXT, config.wantFullContext());
158  flags.set(TIME_SEPARATE, config.wantTimeSeparate());
159  flags.set(EPILOGUE_SEPARATE, config.wantEpilogueSeparate());
160  }
double value
Definition: spectrum.C:18

Member Function Documentation

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

Definition at line 169 of file ELdestination.cc.

References timeFmt_, timeMethod_, and mf::service::ELdestination::StatsCount::~StatsCount().

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

170  {
171  size_t constexpr SIZE{144};
172  string ret;
173  if (timeMethod_ == 0) {
174  return ret;
175  }
176  struct tm timebuf;
177  char ts[SIZE];
178  if (timeMethod_ == 1) {
179  strftime(
180  ts, sizeof(ts), timeFmt_.data(), localtime_r(&t.tv_sec, &timebuf));
181  ret = ts;
182  return ret;
183  }
184  char tmpts[SIZE];
185  strftime(
186  tmpts, sizeof(tmpts), timeFmt_.data(), localtime_r(&t.tv_sec, &timebuf));
187  snprintf(ts, sizeof(ts), tmpts, static_cast<unsigned>(t.tv_usec / 1000));
188  ret = ts;
189  return ret;
190  }
bool mf::service::ELdestination::MsgFormatSettings::want ( flag_enum const  FLAG) const

Definition at line 163 of file ELdestination.cc.

References flags.

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

164  {
165  return flags.test(FLAG);
166  }

Member Data Documentation

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

Definition at line 120 of file ELdestination.h.

Referenced by MsgFormatSettings(), and want().

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

Definition at line 121 of file ELdestination.h.

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

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

Definition at line 125 of file ELdestination.h.

Referenced by MsgFormatSettings(), and timestamp().

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

Definition at line 124 of file ELdestination.h.

Referenced by MsgFormatSettings(), and timestamp().


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