Classes | Public Member Functions | Public Attributes | Private Attributes | List of all members
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 131 of file ELdestination.cc.

132  : timeMethod_{0}, timeFmt_{}
133  {
134  auto const& value = config.timestamp();
135  bool const use_timestamp = (value != "none"s);
136  flags.set(TIMESTAMP, use_timestamp);
137  if (!use_timestamp) {
138  timeMethod_ = 0;
139  } else if (value == "default"s) {
140  timeMethod_ = 1;
141  timeFmt_ = "%d-%b-%Y %H:%M:%S %Z"s;
142  } else if (value == "default_ms"s) {
143  timeMethod_ = 2;
144  timeFmt_ = "%d-%b-%Y %H:%M:%S.%%03u %Z"s;
145  } else {
146  timeMethod_ = 1;
147  timeFmt_ = value;
148  }
149  lineLength = config.noLineBreaks() ? 32000ull : config.lineLength();
151  flags.set(MODULE, config.wantModule());
153  flags.set(TEXT, config.wantText());
155  flags.set(SERIAL, config.wantSerial());
159  }
fhicl::Atom< unsigned long long > lineLength
static Config * config
Definition: config.cpp:1054
static QCString * s
Definition: config.cpp:1042

Member Function Documentation

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

Definition at line 168 of file ELdestination.cc.

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

Definition at line 162 of file ELdestination.cc.

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

Member Data Documentation

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

Definition at line 120 of file ELdestination.h.

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

Definition at line 121 of file ELdestination.h.

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

Definition at line 125 of file ELdestination.h.

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

Definition at line 124 of file ELdestination.h.


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