1 #ifndef messagefacility_MessageLogger_MessageLogger_h 2 #define messagefacility_MessageLogger_MessageLogger_h 11 #include <type_traits> 26 std::string
const& applicationName =
"");
90 decltype(
auto) operator<<(
char const*)
92 return std::forward<NeverLogger_>(*this);
96 decltype(
auto) operator<<(T const&)
98 return std::forward<NeverLogger_>(*this);
102 operator<<(
std::ostream& (*)(
std::ostream&))
104 return std::forward<NeverLogger_>(*this);
107 operator<<(
std::ios_base& (*)(
std::ios_base&))
109 return std::forward<NeverLogger_>(*this);
113 template <ELseverityLevel::ELsev_ SEV,
bool VERBATIM>
123 if (msg_ ==
nullptr) {
141 std::string
const&
file =
"",
146 std::string filename{
file};
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);
154 msg_ = std::move(std::make_unique<ErrorObj>(
155 SEV, category, VERBATIM, filename, line_number));
161 decltype(
auto) operator<<(
char const*
s)
166 return std::forward<MaybeLogger_>(*this);
171 operator<<(T const& t)
176 return std::forward<MaybeLogger_>(*this);
185 return std::forward<MaybeLogger_>(*this);
189 operator<<(
std::ios_base& (*
f)(
std::ios_base&))
194 return std::forward<MaybeLogger_>(*this);
198 std::unique_ptr<ErrorObj> msg_{};
228 #define LOG_INFO(category) mf::LogInfo(category, __FILE__, __LINE__) 229 #define LOG_WARNING(category) mf::LogWarning(category, __FILE__, __LINE__) 230 #define LOG_ERROR(category) mf::LogError(category, __FILE__, __LINE__) 231 #define LOG_SYSTEM(category) mf::LogSystem(category, __FILE__, __LINE__) 235 #define LOG_VERBATIM(category) mf::LogVerbatim(category, __FILE__, __LINE__) 236 #define LOG_PRINT(category) mf::LogPrint(category, __FILE__, __LINE__) 237 #define LOG_PROBLEM(category) mf::LogProblem(category, __FILE__, __LINE__) 238 #define LOG_ABSOLUTE(category) mf::LogAbsolute(category, __FILE__, __LINE__) 240 #undef EDM_MESSAGELOGGER_SUPPRESS_LOGDEBUG 244 #if defined(NDEBUG) || defined(ML_NDEBUG) 245 #define EDM_MESSAGELOGGER_SUPPRESS_LOGDEBUG 246 #endif // NDEBUG || ML_NDEBUG 251 #undef EDM_MESSAGELOGGER_SUPPRESS_LOGDEBUG 254 #ifdef EDM_MESSAGELOGGER_SUPPRESS_LOGDEBUG 256 #define LOG_DEBUG(id) \ 258 #define LOG_TRACE(id) \ 261 #else // EDM_MESSAGELOGGER_SUPPRESS_LOGDEBUG 263 #define LOG_DEBUG(id) \ 264 mf::LogDebug { id, __FILE__, __LINE__ } 265 #define LOG_TRACE(id) \ 266 mf::LogTrace { id, __FILE__, __LINE__ } 268 #endif // EDM_MESSAGELOGGER_SUPPRESS_LOGDEBUG 270 #undef EDM_MESSAGELOGGER_SUPPRESS_LOGDEBUG MaybeLogger_(std::string const &category, std::string const &file="", int line_number=0)
void SetIteration(string const &val)
void SetHostAddr(string const &hostaddr)
void EndMessageFacility()
MaybeLogger_(MaybeLogger_ &&rhs) noexcept
string const & GetModuleName()
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)
string const & GetApplicationName()
string const & GetHostAddr()