SFrame 3.6
SLogger Class Reference

Universal message logging class. More...

#include <core/include/SLogger.h>

Inheritance diagram for SLogger:
Collaboration diagram for SLogger:

List of all members.

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.
SLoggeroperator= (const SLogger &parent)
 Copy operator.
SLoggeroperator<< (SLogger &(*_f)(SLogger &))
 Operator accepting SLogger stream modifiers.
SLoggeroperator<< (std::ostream &(*_f)(std::ostream &))
 Operator accepting std::ostream stream modifiers.
SLoggeroperator<< (std::ios &(*_f)(std::ios &))
 Operator accepting std::ios stream modifiers.
SLoggeroperator<< (SMsgType type)
 Operator accepting message type setting.
template<class T >
SLoggeroperator<< (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 SLoggerendmsg (SLogger &logger)
 Stream modifier to send a message.

Detailed Description

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.

See also:
SLogWriter
SMsgType
Version:
Revision:
331

Definition at line 45 of file SLogger.h.


Constructor & Destructor Documentation

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.

Parameters:
sourcePointer 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.

Parameters:
sourceName 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.

Parameters:
parentThe SLogger object that should be cloned
See also:
SLogger::operator=

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.


Member Function Documentation

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().

SLogger & SLogger::operator<< ( SMsgType  type) [inline]

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;

Definition at line 158 of file SLogger.h.

template<class T >
SLogger& SLogger::operator<< ( 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().

SLogger & SLogger::operator<< ( SLogger &(*)(SLogger &)  _f) [inline]

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.

Definition at line 119 of file SLogger.h.

SLogger & SLogger::operator= ( const SLogger parent)

Copy operator.

Operator for copying the configuration of one SLogger object into another. It is mostly used by the copy constructor.

Parameters:
parentThe SLogger object that should be cloned
See also:
SLogger(const SLogger&)

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.

Parameters:
typeThe type of the message to send
messageThe text of the message

Definition at line 135 of file SLogger.cxx.

References MAXIMUM_SOURCE_NAME_LENGTH, Send(), and SLogWriter::Write().

Referenced by endmsg(), and Send().

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.


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