All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Public Member Functions | Private Attributes | List of all members
icarus::ns::util::mfLoggingClass Class Reference

Helper for logging classes. More...

#include <mfLoggingClass.h>

Inheritance diagram for icarus::ns::util::mfLoggingClass:
icarus::trigger::ApplyBeamGateClass icarus::trigger::CryostatTriggerCombiner icarus::trigger::GeometryChannelSplitter icarus::trigger::MajorityTriggerCombiner icarus::trigger::SlidingWindowPatternAlg icarus::trigger::WindowTopologyAlg icarus::trigger::WindowTopologyManager icarus::trigger::WindowTopologyVerification

Public Member Functions

 mfLoggingClass (std::string const &logCategory)
 Constructor: initializes with the specified log category. More...
 
std::string logCategory () const
 Returns the logging category string for this object. More...
 
mfLoggingClass const & loggingClass () const
 Returns this object (as a logging class object). More...
 
Access to temporary loggers

These methods return a temporary logger for fast logging:

mfLogError() << "That was not a smart thing to do!";

The returned log can also be made a bit less temporary if some more complex output is required:

if (!reasons.empty()) {
auto log = mfLogError();
log << "That was not a smart thing to do, for "
<< size(reasons) << " reasons:";
for (auto const& [ iReason, reason ]: util::enumerate(reasons))
log << "\n " << (iReason+1) << ": " << reason;
} // if

The file and lineNumber argument are optional and passed directly to the logger on construction. If specified, they provide information about the location of the message source:

mfLogError(__FILE__, __LINE__) << "That was not a smart thing to do!";
Note
With C++20 it will be possible to extend the implementation to allow for automatic detection of the call location.
mf::LogError mfLogError (std::string const &file={}, int const lineNumber=0) const
 Returns a mf::LogError() stream for logging. More...
 
mf::LogWarning mfLogWarning (std::string const &file={}, int const lineNumber=0) const
 Returns a mf::LogWarning() stream for logging. More...
 
mf::LogProblem mfLogProblem (std::string const &file={}, int const lineNumber=0) const
 Returns a mf::LogProblem() stream for logging. More...
 
mf::LogInfo mfLogInfo (std::string const &file={}, int const lineNumber=0) const
 Returns a mf::LogInfo() stream for logging. More...
 
mf::LogVerbatim mfLogVerbatim (std::string const &file={}, int const lineNumber=0) const
 Returns a mf::LogVerbatim() stream for logging. More...
 
mf::LogDebug mfLogDebug (std::string const &file={}, int const lineNumber=0) const
 Returns a mf::LogDebug() stream for logging. More...
 
mf::LogTrace mfLogTrace (std::string const &file={}, int const lineNumber=0) const
 Returns a mf::LogTrace() stream for logging. More...
 

Private Attributes

std::string fLogCategory
 Logging category string used for the messages. More...
 

Detailed Description

Helper for logging classes.

A derived class can utilize the member functions of this class for easier tracking of the boilerplate category:

struct Algorithm: private icarus::mfLoggingClass {
Algorithm(): icarus::ns::util::mfLoggingClass("Algorithm") {}
double compute() const
{
mfLogInfo() << "Starting computation()";
return 0.0;
}
}; // class Algorithm

Definition at line 44 of file mfLoggingClass.h.

Constructor & Destructor Documentation

icarus::ns::util::mfLoggingClass::mfLoggingClass ( std::string const &  logCategory)
inline

Constructor: initializes with the specified log category.

Definition at line 51 of file mfLoggingClass.h.

std::string fLogCategory
Logging category string used for the messages.
std::string logCategory() const
Returns the logging category string for this object.

Member Function Documentation

std::string icarus::ns::util::mfLoggingClass::logCategory ( ) const
inline

Returns the logging category string for this object.

Definition at line 54 of file mfLoggingClass.h.

54 { return fLogCategory; }
std::string fLogCategory
Logging category string used for the messages.
mfLoggingClass const& icarus::ns::util::mfLoggingClass::loggingClass ( ) const
inline

Returns this object (as a logging class object).

Definition at line 57 of file mfLoggingClass.h.

57 { return *this; }
mf::LogDebug icarus::ns::util::mfLoggingClass::mfLogDebug ( std::string const &  file = {},
int const  lineNumber = 0 
) const
inline

Returns a mf::LogDebug() stream for logging.

Definition at line 119 of file mfLoggingClass.h.

119  {}, int const lineNumber = 0) const
120  { return { logCategory(), file, lineNumber }; }
* file
Definition: file_to_url.sh:69
std::string logCategory() const
Returns the logging category string for this object.
mf::LogError icarus::ns::util::mfLoggingClass::mfLogError ( std::string const &  file = {},
int const  lineNumber = 0 
) const
inline

Returns a mf::LogError() stream for logging.

Definition at line 94 of file mfLoggingClass.h.

94  {}, int const lineNumber = 0) const
95  { return { logCategory(), file, lineNumber }; }
* file
Definition: file_to_url.sh:69
std::string logCategory() const
Returns the logging category string for this object.
mf::LogInfo icarus::ns::util::mfLoggingClass::mfLogInfo ( std::string const &  file = {},
int const  lineNumber = 0 
) const
inline

Returns a mf::LogInfo() stream for logging.

Definition at line 109 of file mfLoggingClass.h.

109  {}, int const lineNumber = 0) const
110  { return { logCategory(), file, lineNumber }; }
* file
Definition: file_to_url.sh:69
std::string logCategory() const
Returns the logging category string for this object.
mf::LogProblem icarus::ns::util::mfLoggingClass::mfLogProblem ( std::string const &  file = {},
int const  lineNumber = 0 
) const
inline

Returns a mf::LogProblem() stream for logging.

Definition at line 104 of file mfLoggingClass.h.

104  {}, int const lineNumber = 0) const
105  { return { logCategory(), file, lineNumber }; }
* file
Definition: file_to_url.sh:69
std::string logCategory() const
Returns the logging category string for this object.
mf::LogTrace icarus::ns::util::mfLoggingClass::mfLogTrace ( std::string const &  file = {},
int const  lineNumber = 0 
) const
inline

Returns a mf::LogTrace() stream for logging.

Definition at line 124 of file mfLoggingClass.h.

124  {}, int const lineNumber = 0) const
125  { return { logCategory(), file, lineNumber }; }
* file
Definition: file_to_url.sh:69
std::string logCategory() const
Returns the logging category string for this object.
mf::LogVerbatim icarus::ns::util::mfLoggingClass::mfLogVerbatim ( std::string const &  file = {},
int const  lineNumber = 0 
) const
inline

Returns a mf::LogVerbatim() stream for logging.

Definition at line 114 of file mfLoggingClass.h.

114  {}, int const lineNumber = 0) const
115  { return { logCategory(), file, lineNumber }; }
* file
Definition: file_to_url.sh:69
std::string logCategory() const
Returns the logging category string for this object.
mf::LogWarning icarus::ns::util::mfLoggingClass::mfLogWarning ( std::string const &  file = {},
int const  lineNumber = 0 
) const
inline

Returns a mf::LogWarning() stream for logging.

Definition at line 99 of file mfLoggingClass.h.

99  {}, int const lineNumber = 0) const
100  { return { logCategory(), file, lineNumber }; }
* file
Definition: file_to_url.sh:69
std::string logCategory() const
Returns the logging category string for this object.

Member Data Documentation

std::string icarus::ns::util::mfLoggingClass::fLogCategory
private

Logging category string used for the messages.

Definition at line 46 of file mfLoggingClass.h.


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