LArSoft  v07_13_02
Liquid Argon Software toolkit - http://larsoft.org/
mf::MaybeLogger_< SEV, VERBATIM > Class Template Reference

#include "MessageLogger.h"

Public Member Functions

 MaybeLogger_ (MaybeLogger_ const &)=delete
 
MaybeLogger_operator= (MaybeLogger_ const &)=delete
 
MaybeLogger_operator= (MaybeLogger_ &&)=delete
 
 ~MaybeLogger_ ()
 
 MaybeLogger_ ()
 
 MaybeLogger_ (MaybeLogger_ &&rhs) noexcept
 
 MaybeLogger_ (std::string const &category, std::string const &file="", int line_number=0)
 
decltype(auto) operator<< (char const *s)
 
template<class T >
decltype(auto) operator<< (T const &t)
 
decltype(auto) operator<< (std::ostream &(*f)(std::ostream &))
 
decltype(auto) operator<< (std::ios_base &(*f)(std::ios_base &))
 

Private Attributes

std::unique_ptr< ErrorObjmsg_ {}
 

Detailed Description

template<ELseverityLevel::ELsev_ SEV, bool VERBATIM>
class mf::MaybeLogger_< SEV, VERBATIM >

Definition at line 114 of file MessageLogger.h.

Constructor & Destructor Documentation

template<ELseverityLevel::ELsev_ SEV, bool VERBATIM>
mf::MaybeLogger_< SEV, VERBATIM >::MaybeLogger_ ( MaybeLogger_< SEV, VERBATIM > const &  )
delete
template<ELseverityLevel::ELsev_ SEV, bool VERBATIM>
mf::MaybeLogger_< SEV, VERBATIM >::~MaybeLogger_ ( )
inline

Definition at line 121 of file MessageLogger.h.

References mf::GetIteration(), mf::GetModuleName(), and mf::LogErrorObj().

122  {
123  if (msg_ == nullptr) {
124  return;
125  }
126  try {
127  msg_->setModule(GetModuleName());
128  msg_->setIteration(GetIteration());
129  LogErrorObj(msg_.release());
130  }
131  catch (...) {
132  // FIXME: We should never ignore errors!
133  }
134  }
string const & GetModuleName()
std::unique_ptr< ErrorObj > msg_
string const & GetIteration()
void LogErrorObj(ErrorObj *msg)
template<ELseverityLevel::ELsev_ SEV, bool VERBATIM>
mf::MaybeLogger_< SEV, VERBATIM >::MaybeLogger_ ( )
inline

Definition at line 136 of file MessageLogger.h.

136 : msg_{} {}
std::unique_ptr< ErrorObj > msg_
template<ELseverityLevel::ELsev_ SEV, bool VERBATIM>
mf::MaybeLogger_< SEV, VERBATIM >::MaybeLogger_ ( MaybeLogger_< SEV, VERBATIM > &&  rhs)
inlinenoexcept

Definition at line 138 of file MessageLogger.h.

138 : msg_{std::move(rhs.msg_)} {}
std::unique_ptr< ErrorObj > msg_
template<ELseverityLevel::ELsev_ SEV, bool VERBATIM>
mf::MaybeLogger_< SEV, VERBATIM >::MaybeLogger_ ( std::string const &  category,
std::string const &  file = "",
int  line_number = 0 
)
inline

Definition at line 140 of file MessageLogger.h.

References file.

143  : msg_{}
144  {
145  // Verbatim messages have the full file path, otherwise just the basename.
146  std::string filename{file};
147  if (!VERBATIM) {
148  auto const lastSlash = file.find_last_of('/');
149  if ((lastSlash != std::string::npos) &&
150  (lastSlash != (file.size() - 1))) {
151  filename = file.substr(lastSlash + 1, file.size() - lastSlash - 1);
152  }
153  }
154  msg_ = std::move(std::make_unique<ErrorObj>(
155  SEV, category, VERBATIM, filename, line_number));
156  }
std::unique_ptr< ErrorObj > msg_
TFile * file

Member Function Documentation

template<ELseverityLevel::ELsev_ SEV, bool VERBATIM>
decltype(auto) mf::MaybeLogger_< SEV, VERBATIM >::operator<< ( char const *  s)
inline

Definition at line 161 of file MessageLogger.h.

References s.

162  {
163  if (msg_) {
164  (*msg_) << s;
165  }
166  return std::forward<MaybeLogger_>(*this);
167  }
Float_t s
Definition: plot.C:23
std::unique_ptr< ErrorObj > msg_
template<ELseverityLevel::ELsev_ SEV, bool VERBATIM>
template<class T >
decltype(auto) mf::MaybeLogger_< SEV, VERBATIM >::operator<< ( T const &  t)
inline

Definition at line 171 of file MessageLogger.h.

172  {
173  if (msg_) {
174  (*msg_) << t;
175  }
176  return std::forward<MaybeLogger_>(*this);
177  }
std::unique_ptr< ErrorObj > msg_
template<ELseverityLevel::ELsev_ SEV, bool VERBATIM>
decltype(auto) mf::MaybeLogger_< SEV, VERBATIM >::operator<< ( std::ostream &(*)(std::ostream &)  f)
inline

Definition at line 180 of file MessageLogger.h.

References f.

181  {
182  if (msg_) {
183  (*msg_) << f;
184  }
185  return std::forward<MaybeLogger_>(*this);
186  }
TFile f
Definition: plotHisto.C:6
std::unique_ptr< ErrorObj > msg_
template<ELseverityLevel::ELsev_ SEV, bool VERBATIM>
decltype(auto) mf::MaybeLogger_< SEV, VERBATIM >::operator<< ( std::ios_base &(*)(std::ios_base &)  f)
inline

Definition at line 189 of file MessageLogger.h.

References f.

190  {
191  if (msg_) {
192  (*msg_) << f;
193  }
194  return std::forward<MaybeLogger_>(*this);
195  }
TFile f
Definition: plotHisto.C:6
std::unique_ptr< ErrorObj > msg_
template<ELseverityLevel::ELsev_ SEV, bool VERBATIM>
MaybeLogger_& mf::MaybeLogger_< SEV, VERBATIM >::operator= ( MaybeLogger_< SEV, VERBATIM > const &  )
delete
template<ELseverityLevel::ELsev_ SEV, bool VERBATIM>
MaybeLogger_& mf::MaybeLogger_< SEV, VERBATIM >::operator= ( MaybeLogger_< SEV, VERBATIM > &&  )
delete

Member Data Documentation

template<ELseverityLevel::ELsev_ SEV, bool VERBATIM>
std::unique_ptr<ErrorObj> mf::MaybeLogger_< SEV, VERBATIM >::msg_ {}
private

Definition at line 198 of file MessageLogger.h.


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