GCpp general purpose C++ library  version 1.0
GLogMessage Class Reference

#include <GLogMessage.hh>

Public Member Functions

template<class Q >
bool IsInstanceOf () const
 
template<class Q >
bool IsInstanceOf ()
 
virtual GLogMessageClone () const
 
virtual const char * ClassName () const
 
virtual ~GLogMessage ()
 

Static Public Member Functions

static const char * StaticClassName ()
 
static u_int GetVerboseLevel ()
 
static void SetVerboseLevel (u_int v)
 
static void SetLogFile (const string &fname, bool term=true)
 
static void CloseLogFile ()
 
static void SendLogMessage (const string &text, u_int verb=1)
 
static void SendLogMessage (const string &text, u_int verb, u_int ref_level)
 
static void SendLogInfo (const string &text)
 
static void SendLogWarning (const string &text)
 
static void SengLogError (const string &text, bool abort=true)
 
static void SendLogMessage (ostream &os, const string &text, u_int verb=1)
 
static void SendLogMessage (ostream &os, const string &text, u_int verb, u_int ref_level)
 
static void SendLogInfo (ostream &os, const string &text)
 
static void SendLogWarning (ostream &os, const string &text)
 
static void SengLogError (ostream &os, const string &text, bool abort=true)
 

Protected Member Functions

 GLogMessage ()
 

Static Protected Attributes

static u_int verbose_level = 0
 Current verbose level.
 
static bool log_file = false
 Indicates if there is a log file.
 
static bool log_term = true
 Indicates if there is a log output on terminal.
 
static string log_file_name = ""
 Log file name.
 
static ofstream log_file_stream
 Log file stream.
 

Detailed Description

This class provides a set of static functions to send messages to a terminal output and/or to a log file.

The different types of text messages are the following:

  • Info : a message with information marker (prefix)
  • Warning : a message with warning marker (prefix) and highlightiong.
  • Error : a message with error marker (prefix) and highlightiong, than may also stop the program.
  • Message : a message with no marker, but with a user-defined verbose level condition

Constructor & Destructor Documentation

GLogMessage::GLogMessage ( )
inlineprotected

Constructor: no need, use static functions.

GLogMessage::~GLogMessage ( )
inlinevirtual

Destructor.

References CloseLogFile().

Member Function Documentation

void GLogMessage::CloseLogFile ( )
static

Close the log file (if it was open...). Then the terminal log output is set on.

References log_file, log_file_stream, and log_term.

Referenced by GCloseLogFile(), SetLogFile(), and ~GLogMessage().

u_int GLogMessage::GetVerboseLevel ( )
inlinestatic

Return the verbose level for information messages.

References verbose_level.

Referenced by GGetVerboseLevel().

template<class Q >
bool GLogMessage::IsInstanceOf ( ) const
inline

Macro from GCpp library that defines the following functions:

  • ClassName(): return the real class name of the object
  • StaticClassName(): return the used class name of the object (that may be a base class of the real object).
  • IsInstanceOf<T>(): return true if the current object is an instance of the template class name argument
  • Clone(): return an allocated copy of the object.
void GLogMessage::SendLogInfo ( const string &  text)
inlinestatic

Send an information message to the standard output stream.

Parameters
texttext to be displayed

Referenced by GLogInfo().

void GLogMessage::SendLogInfo ( ostream &  os,
const string &  text 
)
static

Send an information message (special prefix) to an output stream.

Parameters
osoutput stream
texttext to be displayed

References gPrefixInfo, gSuffixInfo, log_term, and SendLogMessage().

void GLogMessage::SendLogMessage ( const string &  text,
u_int  verb = 1 
)
inlinestatic

Send a message to the standard output stream, if the argument verbose value is lower or equal to current verbose level. Set the verb value to 0 to display the message in any case.

Parameters
texttext to be displayed
verbrequested verbose level to display the message

Referenced by GLogMessage(), SendLogInfo(), SendLogMessage(), SendLogWarning(), and SengLogError().

void GLogMessage::SendLogMessage ( const string &  text,
u_int  verb,
u_int  ref_level 
)
inlinestatic

Send a message to the standard output stream, if the argument verbose value is lower or equal to the external reference verbose level ref_level. This function is for use with packages that define their own verbose level. Set the verb value to 0 to display the message in any case.

Parameters
texttext to be displayed
verbrequested verbose level to display the message
ref_levelexternal reference verbose level

References SendLogMessage().

void GLogMessage::SendLogMessage ( ostream &  os,
const string &  text,
u_int  verb = 1 
)
static

Send a message to an output stream, if the argument verbose value is lower or equal to current verbose level. Set the verb value to 0 to display the message in any case.

Parameters
osoutput stream
texttext to be displayed
verbrequested run manager verbose level to display the message

References log_file, log_file_stream, log_term, and verbose_level.

void GLogMessage::SendLogMessage ( ostream &  os,
const string &  text,
u_int  verb,
u_int  ref_level 
)
static

Send a message to an output stream, if the argument verbose value is lower or equal to the external reference verbose level ref_level. This function is for use with packages that define their own verbose level. Set the verb value to 0 to display the message in any case.

Parameters
osoutput stream
texttext to be displayed
verbrequested run manager verbose level to display the message
ref_levelexternal reference verbose level

References log_file, log_file_stream, and log_term.

void GLogMessage::SendLogWarning ( const string &  text)
inlinestatic

Send a warning message (special highlighting) to the standard error stream.

Parameters
texttext to be displayed

Referenced by GLogWarning().

void GLogMessage::SendLogWarning ( ostream &  os,
const string &  text 
)
static

Send a warning message (special highlighting) to an output stream.

Parameters
osoutput stream
texttext to be displayed

References gPrefixWarning, gSuffixWarning, log_term, and SendLogMessage().

void GLogMessage::SengLogError ( const string &  text,
bool  abort = true 
)
inlinestatic

Send an error message (special highlighting) to the standard error stream. The program is then interrupted, except if abort is set to false.

Parameters
texttext to be displayed
abortindicates if program should crash

Referenced by GLogError().

void GLogMessage::SengLogError ( ostream &  os,
const string &  text,
bool  abort = true 
)
static

Send an error message (special highlighting) to an output stream. The program is then interrupted, except if abort is set to false.

Parameters
osoutput stream
texttext to be displayed
abortindicates if program should crash

References gPrefixError, gSuffixError, log_term, and SendLogMessage().

void GLogMessage::SetLogFile ( const string &  fname,
bool  term = true 
)
static

Indicate a log file name for simulation messages. When messages are sent to a log file, it is possible to switch off the terminal messages, if argument term is set to false.

Parameters
fnamename of the log-file
termindicate if terminal output is ON/OFF (default is ON)

References CloseLogFile(), GLogWarning(), log_file, log_file_name, log_file_stream, and log_term.

Referenced by GSetLogFile().

void GLogMessage::SetVerboseLevel ( u_int  v)
inlinestatic

Set the verbose level for information messages.

Parameters
vnew verbose level

References verbose_level.

Referenced by GSetVerboseLevel().


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