SFrame 3.6
|
Universal message logging class. More...
#include <core/include/SLogger.h>
Public Member Functions | |
SLogger (const TObject *source) | |
Constructor with pointer to the parent object. | |
SLogger (const std::string &source) | |
Constructor with a name of the parent object. | |
SLogger (const SLogger &parent) | |
Copy constructor. | |
virtual | ~SLogger () |
Default destructor. | |
void | SetSource (const TObject *source) |
Set the source name using a TObject parent. | |
void | SetSource (const std::string &source) |
Set the source name using a simple string. | |
const char * | GetSource () const |
Get the source string of the logger. | |
SLogger & | operator= (const SLogger &parent) |
Copy operator. | |
SLogger & | operator<< (SLogger &(*_f)(SLogger &)) |
Operator accepting SLogger stream modifiers. | |
SLogger & | operator<< (std::ostream &(*_f)(std::ostream &)) |
Operator accepting std::ostream stream modifiers. | |
SLogger & | operator<< (std::ios &(*_f)(std::ios &)) |
Operator accepting std::ios stream modifiers. | |
SLogger & | operator<< (SMsgType type) |
Operator accepting message type setting. | |
template<class T > | |
SLogger & | operator<< (T arg) |
Operator accepting basically any kind of argument. | |
void | Send (SMsgType type, const std::string &message) const |
Old style message sender function. | |
Static Public Member Functions | |
static SLogger & | endmsg (SLogger &logger) |
Stream modifier to send a message. |
Universal message logging class.
Class that should be used in the whole framework for printing messages on the terminal. It produces nicely formatted log messages using the SLogWriter class.
It prints the source of each message which makes reading debugging messages a bit easier. Every message has a type. This type controls how/if they should be printed to the terminal with the current configuration.
SLogger::SLogger | ( | const TObject * | source | ) |
Constructor with pointer to the parent object.
Many classes in SFrame inherit from TObject. It makes it quite easy to show the correct name of the class sending the message through the TObject functionality.
For instance the SLogger object defined in SCycleBaseBase will print the correct name of the user analysis cycle, even though the user doesn't have to set anything for this.
source | Pointer to the object that will print the messages (usually "this") |
Definition at line 39 of file SLogger.cxx.
References SLogWriter::Instance().
SLogger::SLogger | ( | const std::string & | source | ) |
Constructor with a name of the parent object.
Since SLogger has to be usable by classes not inheriting from TObject as well, the user can create it with specifying an std::string name under which the messages should be displayed.
source | Name of the component sending the messages |
Definition at line 53 of file SLogger.cxx.
References SLogWriter::Instance().
SLogger::SLogger | ( | const SLogger & | parent | ) |
Copy constructor.
This constructor is necessary to be able to freely copy objects using SLogger.
parent | The SLogger object that should be cloned |
Definition at line 67 of file SLogger.cxx.
SLogger::~SLogger | ( | ) | [virtual] |
Default destructor.
The destructor is literally not doing anything...
Definition at line 78 of file SLogger.cxx.
Stream modifier to send a message.
This is just a convenience function to be able to just use the "<<" operator for printing messages. This stream modifier acts very similarly to std::endl. You can use it like:
logger << "Some text" << SLogger::endmsg;
Definition at line 211 of file SLogger.cxx.
References Send().
Referenced by SCycleConfig::ArrangeInputData(), SCycleBaseNTuple::ConnectVariable(), SCycleBaseNTuple::CreateOutputTrees(), SCycleBaseNTuple::DeclareVariable(), SCycleController::ExecuteAllCycles(), SCycleController::ExecuteNextCycle(), SInputData::GetTotalLumi(), SCycleController::Initialize(), SCycleBaseConfig::Initialize(), SCycleBaseConfig::InitializeInputData(), SCycleBaseConfig::InitializeUserConfig(), SCycleBaseNTuple::LoadInputTrees(), SParLocator::Locate(), ProofSummedVar< Type >::Merge(), SFileMerger::Merge(), SCycleStatistics::Merge(), SCycleOutput::Merge(), SCycleBaseExec::Notify(), SProofManager::Open(), SInputData::Print(), SCycleConfig::PrintConfig(), SCycleBaseExec::Process(), SCycleBaseHist::RetrieveAll(), SErrorHandler(), SCycleBaseConfig::SetProperty(), SetSErrorHandler(), SCycleBaseExec::SlaveBegin(), SCycleBaseExec::SlaveTerminate(), SH1< Type >::ToHist(), SInputData::ValidateInput(), SCycleStatistics::Write(), SCycleOutput::Write(), and SCycleBaseHist::WriteHistObjects().
const char * SLogger::GetSource | ( | ) | const |
Get the source string of the logger.
Definition at line 98 of file SLogger.cxx.
SLogger & SLogger::operator<< | ( | std::ios &(*)(std::ios &) | _f | ) | [inline] |
Operator accepting std::ios stream modifiers.
This operator handles all stream modifiers that have been written to work on std::ios objects. I have to admit I don't remember exactly which operators these are, but some formatting operations need this.
Definition at line 142 of file SLogger.h.
References SLogWriter::GetMinType().
Operator accepting message type setting.
Messages have a type, defined by the SMsgType enumeration. This operator allows the user to write intuitive message lines in the code like this:
logger << INFO << "This is an info message" << SLogger::endmsg;
SLogger& SLogger::operator<< | ( | T | arg | ) | [inline] |
Operator accepting basically any kind of argument.
SLogger was designed to give all the features that std::ostream objects usually provide. This operator handles all kinds of arguments and passes it on to the std::ostringstream base class.
Definition at line 87 of file SLogger.h.
References SLogWriter::GetMinType().
SLogger & SLogger::operator<< | ( | std::ostream &(*)(std::ostream &) | _f | ) | [inline] |
Operator accepting std::ostream stream modifiers.
This operator handles all stream modifiers that have been written to work on std::ostream objects. Most of the message formatting modifiers are such.
Definition at line 129 of file SLogger.h.
References SLogWriter::GetMinType().
Operator accepting SLogger stream modifiers.
This operator handles all stream modifiers that have been written to work on SLogger objects specifically. Right now there is basically only the SLogger::endmsg stream modifier that is such.
Copy operator.
Operator for copying the configuration of one SLogger object into another. It is mostly used by the copy constructor.
parent | The SLogger object that should be cloned |
Definition at line 114 of file SLogger.cxx.
References SLogWriter::Instance().
void SLogger::Send | ( | SMsgType | type, |
const std::string & | message | ||
) | const |
Old style message sender function.
This function does the heavy-lifting of the message sending. It doesn't use any of the std::ostringstream functionality itself. It receives the type of the message and the message itself. If the type is such that it should be displayed, it slices the message into multiple lines and sends it line-by-line to SLogWriter.
type | The type of the message to send |
message | The text of the message |
Definition at line 135 of file SLogger.cxx.
References MAXIMUM_SOURCE_NAME_LENGTH, Send(), and SLogWriter::Write().
void SLogger::SetSource | ( | const TObject * | source | ) |
Set the source name using a TObject parent.
Definition at line 82 of file SLogger.cxx.
Referenced by SToolBaseT< Type >::SetLogName(), and SCycleBaseBase::SetLogName().
void SLogger::SetSource | ( | const std::string & | source | ) |
Set the source name using a simple string.
Definition at line 90 of file SLogger.cxx.