1 #ifndef messagefacility_MessageLogger_MessageLogger_h 2 #define messagefacility_MessageLogger_MessageLogger_h 11 #include <type_traits> 24 std::string
const& applicationName =
"");
88 operator<<(
char const*)
90 return std::forward<NeverLogger_>(*this);
97 return std::forward<NeverLogger_>(*this);
101 operator<<(
std::ostream& (*)(
std::ostream&))
103 return std::forward<NeverLogger_>(*this);
106 operator<<(
std::ios_base& (*)(
std::ios_base&))
108 return std::forward<NeverLogger_>(*this);
112 template <ELseverityLevel::ELsev_ SEV,
bool VERBATIM>
121 if (msg_ ==
nullptr) {
138 std::string
const&
file = {},
139 int const line_number = 0)
142 std::string filename{
file};
144 auto const lastSlash =
file.find_last_of(
'/');
145 if ((lastSlash != std::string::npos) &&
146 (lastSlash != (
file.size() - 1))) {
147 filename =
file.substr(lastSlash + 1,
file.size() - lastSlash - 1);
150 msg_ = std::make_unique<ErrorObj>(
151 SEV, category, VERBATIM, filename, line_number);
158 operator<<(
char const* s)
163 return std::forward<MaybeLogger_>(*this);
168 operator<<(T const& t)
173 return std::forward<MaybeLogger_>(*this);
182 return std::forward<MaybeLogger_>(*this);
186 operator<<(
std::ios_base& (*
f)(
std::ios_base&))
191 return std::forward<MaybeLogger_>(*this);
195 std::unique_ptr<ErrorObj> msg_{
nullptr};
225 #define MF_LOG_INFO(category) \ 228 category, __FILE__, __LINE__ \ 230 #define MF_LOG_WARNING(category) \ 233 category, __FILE__, __LINE__ \ 235 #define MF_LOG_ERROR(category) \ 238 category, __FILE__, __LINE__ \ 240 #define MF_LOG_SYSTEM(category) \ 243 category, __FILE__, __LINE__ \ 248 #define MF_LOG_VERBATIM(category) \ 251 category, __FILE__, __LINE__ \ 253 #define MF_LOG_PRINT(category) \ 256 category, __FILE__, __LINE__ \ 258 #define MF_LOG_PROBLEM(category) \ 261 category, __FILE__, __LINE__ \ 263 #define MF_LOG_ABSOLUTE(category) \ 266 category, __FILE__, __LINE__ \ 269 #undef MF_SUPPRESS_LOG_DEBUG 273 #if defined(NDEBUG) || defined(MF_NDEBUG) 274 #define MF_SUPPRESS_LOG_DEBUG 275 #endif // NDEBUG || MF_NDEBUG 280 #undef MF_SUPPRESS_LOG_DEBUG 283 #ifdef MF_SUPPRESS_LOG_DEBUG 285 #define MF_LOG_DEBUG(id) \ 288 #define MF_LOG_TRACE(id) \ 292 #else // MF_SUPPRESS_LOG_DEBUG 294 #define MF_LOG_DEBUG(id) \ 297 id, __FILE__, __LINE__ \ 299 #define MF_LOG_TRACE(id) \ 302 id, __FILE__, __LINE__ \ 305 #endif // MF_SUPPRESS_LOG_DEBUG 307 #undef MF_SUPPRESS_LOG_DEBUG void SetIteration(string const &val)
void SetHostAddr(string const &hostaddr)
void EndMessageFacility()
string const & GetModuleName()
MaybeLogger_(std::string const &category, std::string const &file={}, int const line_number=0)
void SetContextIteration(string const &val)
bool isMessageProcessingSetUp()
void StartMessageFacility(fhicl::ParameterSet const &pset, string const &applicationName)
void SetHostName(string const &hostname)
string const & GetHostName()
string const & GetIteration()
void SetContextSinglet(string const &val)
void LogErrorObj(ErrorObj *msg)
void SetModuleName(string const &val)
void SetApplicationName(string const &applicationName)
void SetPid(long const pid)
string const & GetApplicationName()
string const & GetHostAddr()