Glib::Util::LogStream Class Reference

The log stream class. More...

List of all members.

Public Types

enum  LogLevel {
  LOG_LEVEL_NORMAL = 0,
  LOG_LEVEL_VERBOSE
}
enum  StreamType {
  FILE_STREAM = 1,
  COUT_STREAM = 1 >> 1,
  CERR_STREAM = 1 >> 2,
  RFU0,
  RFU1,
  RFU2
}

Public Member Functions

void enable_domain (const string &a_domain, bool a_do_enable=true)
 enable or disable logging for a domain
bool is_domain_enabled (const string &a_domain)
 LogStream (enum LogLevel a_level=LOG_LEVEL_NORMAL, const string &a_default_domain=GLIBMM_GENERAL_DOMAIN)
 default constructor of a LogStream.
LogStreamoperator<< (LogStream &(*a_manipulator)(LogStream &))
 log a stream manipulator
LogStreamoperator<< (char a_char)
 log a character
LogStreamoperator<< (double a_double)
 log a double
LogStreamoperator<< (guint an_int)
 log a guint
LogStreamoperator<< (int an_int)
 log an integer
LogStreamoperator<< (const Glib::ustring &a_string)
 log zero teriminated strings
void pop_domain ()
 pops the last domain that has been pushed using LogStream::push_domain.
void push_domain (const string &a_domain)
 set the domain in against which all the coming messages will be logged.
LogStreamwrite (char a_msg, const string &a_domain=GLIBMM_GENERAL_DOMAIN)
LogStreamwrite (double a_msg, const string &a_domain=GLIBMM_GENERAL_DOMAIN)
LogStreamwrite (guint a_msg, const string &a_domain=GLIBMM_GENERAL_DOMAIN)
LogStreamwrite (int a_msg, const string &a_domain=GLIBMM_GENERAL_DOMAIN)
LogStreamwrite (const Glib::ustring &a_msg, const string &a_domain=GLIBMM_GENERAL_DOMAIN)
 log a message to the stream
LogStreamwrite (const char *a_buf, long a_buflen=-1, const string &a_domain=GLIBMM_GENERAL_DOMAIN)
 writes a text string to the stream
virtual ~LogStream ()
 destructor of the log stream class

Static Public Member Functions

static void activate (bool a_activate)
 activate/de-activate the logging.
static LogStreamdefault_log_stream ()
 gets the log stream instanciated by the system by default.
static const char * get_stream_file_path ()
 gets the log file path, in case the stream type is set to FILE_STREAM
static enum StreamType get_stream_type ()
 gets the type of the instances of LogStream
static bool is_active ()
 tests wether the logging is activated or not.
static void set_log_domain_filter (const char *a_domain, long a_len=-1)
 sets a filter on the log domain only streams that have the same domain as the one set here will be logging data.
static void set_log_level_filter (enum LogLevel a_level)
 sets the log level filter.
static void set_stream_file_path (const char *a_file_path, long a_len=-1)
 in the case where the stream type is set to FILE_STREAM, this methods sets the path of the file to log into.
static void set_stream_type (enum StreamType a_type)
 set the type of all the log streams that will be instanciated (either cout, cerr, or log file).

Friends

LogStreamendl (LogStream &)
 log a '\n' and flushes the stream Use it like: Glib::Util::LogStream out ; out << "hello"<< Glib::Util::endl ;
LogStreamflush (LogStream &)
 flushes the stream Use it like: Glib::Util::LogStream out ; out << "Hello" << Glib::Util::flush ;
LogStreamlevel_normal (LogStream &a_stream)
 sets the log level to normal Use it like Glib::Util::LogStream out ; out << Glib::Util::level_normal << "blabla" ;
LogStreamlevel_verbose (LogStream &a_stream)
 sets the log level to verbose Use it lik: Glib::Util::LogStream out ; out << Glib::Util::level_verbose << "bla bla bla" ;
LogStreamtimestamp (LogStream &)
 logs a timestamp.

Detailed Description

The log stream class.

It features logging to cout, cerr and files. It also features log domains and log levels.


Member Enumeration Documentation

Enumerator:
LOG_LEVEL_NORMAL 
LOG_LEVEL_VERBOSE 
Enumerator:
FILE_STREAM 
COUT_STREAM 
CERR_STREAM 
RFU0 
RFU1 
RFU2 

Constructor & Destructor Documentation

Glib::Util::LogStream::LogStream ( enum LogLevel  a_level = LOG_LEVEL_NORMAL,
const string &  a_default_domain = GLIBMM_GENERAL_DOMAIN 
)

default constructor of a LogStream.

Parameters:
a_level the log level of the stream. This stream will log data if its log level is inferior or equal to the log level filter defined by LogStream::set_log_level_filter().
a_default_domain the log domain. A stream will log data if its its log level is <= to the log level filter, *and* if its domain equals the domain filter.
virtual Glib::Util::LogStream::~LogStream (  )  [virtual]

destructor of the log stream class


Member Function Documentation

static void Glib::Util::LogStream::activate ( bool  a_activate  )  [static]

activate/de-activate the logging.

Parameters:
a_activate true to activate the logging, false to deactivate.
static LogStream& Glib::Util::LogStream::default_log_stream (  )  [static]

gets the log stream instanciated by the system by default.

the options of this log stream are the global options set before the first call to this method.

Returns:
the log stream instanciated by default.
void Glib::Util::LogStream::enable_domain ( const string &  a_domain,
bool  a_do_enable = true 
)

enable or disable logging for a domain

Parameters:
a_domain the domain to enable logging for
a_do_enable when set to true, enables the logging for domain a_domain, disable it otherwise.
static const char* Glib::Util::LogStream::get_stream_file_path (  )  [static]

gets the log file path, in case the stream type is set to FILE_STREAM

Returns:
the path to the log file.
static enum StreamType Glib::Util::LogStream::get_stream_type (  )  [static]

gets the type of the instances of LogStream

Returns:
the stream type as set by LogStream::set_stream_type().
static bool Glib::Util::LogStream::is_active (  )  [static]

tests wether the logging is activated or not.

Returns:
true if the logging is activated, false otherwise.
bool Glib::Util::LogStream::is_domain_enabled ( const string &  a_domain  ) 
Returns:
true if is logging is enabled for domain a_domain
LogStream& Glib::Util::LogStream::operator<< ( LogStream &(*)(LogStream &)  a_manipulator  ) 

log a stream manipulator

Parameters:
a_manipulator the LogStream manipulator to log
LogStream& Glib::Util::LogStream::operator<< ( char  a_char  ) 

log a character

Parameters:
a_char the char to log
LogStream& Glib::Util::LogStream::operator<< ( double  a_double  ) 

log a double

Parameters:
a_double the double to log
LogStream& Glib::Util::LogStream::operator<< ( guint  an_int  ) 

log a guint

Parameters:
an_int the guint to log
LogStream& Glib::Util::LogStream::operator<< ( int  an_int  ) 

log an integer

Parameters:
an_int the integer to log
LogStream& Glib::Util::LogStream::operator<< ( const Glib::ustring &  a_string  ) 

log zero teriminated strings

Parameters:
a_string the string to log
void Glib::Util::LogStream::pop_domain (  ) 

pops the last domain that has been pushed using LogStream::push_domain.

void Glib::Util::LogStream::push_domain ( const string &  a_domain  ) 

set the domain in against which all the coming messages will be logged.

This is to be used in association with the << operators where we cannot specify the domain to log against, unlike LogStream::write() .

Parameters:
a_domain the domain to log against.
static void Glib::Util::LogStream::set_log_domain_filter ( const char *  a_domain,
long  a_len = -1 
) [static]

sets a filter on the log domain only streams that have the same domain as the one set here will be logging data.

Parameters:
a_domain the domain name.
a_len the length of the domain name. If <0, it means that a_domain is a zero terminated string.
static void Glib::Util::LogStream::set_log_level_filter ( enum LogLevel  a_level  )  [static]

sets the log level filter.

if the filter is set to LOG_LEVEL_NORMAL, only the log streams that have a log level set to LOG_LEVEL_NORMAL will actually log data. If the filter is set to LOG_LEVEL_VERBOSE, streams set to LOG_LEVEL_NORMAL *and* streams set to LOG_LEVEL_VERBOSE will be logging data.

Parameters:
a_level the level of verbosity you want your log streams to have.
static void Glib::Util::LogStream::set_stream_file_path ( const char *  a_file_path,
long  a_len = -1 
) [static]

in the case where the stream type is set to FILE_STREAM, this methods sets the path of the file to log into.

By default, the log file is ./log.txt

Parameters:
a_file_path the log file path.
a_len the length of the file_path. If <0, it means that a_file_path is a zero terminated string.
static void Glib::Util::LogStream::set_stream_type ( enum StreamType  a_type  )  [static]

set the type of all the log streams that will be instanciated (either cout, cerr, or log file).

By default, the type of stream is set to COUT_STREAM. All the logs are sent to stdout.

Parameters:
a_type the type of the log stream
LogStream& Glib::Util::LogStream::write ( char  a_msg,
const string &  a_domain = GLIBMM_GENERAL_DOMAIN 
)
LogStream& Glib::Util::LogStream::write ( double  a_msg,
const string &  a_domain = GLIBMM_GENERAL_DOMAIN 
)
LogStream& Glib::Util::LogStream::write ( guint  a_msg,
const string &  a_domain = GLIBMM_GENERAL_DOMAIN 
)
LogStream& Glib::Util::LogStream::write ( int  a_msg,
const string &  a_domain = GLIBMM_GENERAL_DOMAIN 
)
LogStream& Glib::Util::LogStream::write ( const Glib::ustring &  a_msg,
const string &  a_domain = GLIBMM_GENERAL_DOMAIN 
)

log a message to the stream

Parameters:
a_msg the message to log
a_domain the domain to log against
LogStream& Glib::Util::LogStream::write ( const char *  a_buf,
long  a_buflen = -1,
const string &  a_domain = GLIBMM_GENERAL_DOMAIN 
)

writes a text string to the stream

Parameters:
a_buf the buffer that contains the text string.
a_buflen the length of the buffer. If <0, a_buf is considered as a zero terminated string.
a_domain the domain the string has to be logged against.

Friends And Related Function Documentation

LogStream& endl ( LogStream  )  [friend]

log a '\n' and flushes the stream Use it like: Glib::Util::LogStream out ; out << "hello"<< Glib::Util::endl ;

LogStream& flush ( LogStream  )  [friend]

flushes the stream Use it like: Glib::Util::LogStream out ; out << "Hello" << Glib::Util::flush ;

LogStream& level_normal ( LogStream a_stream  )  [friend]

sets the log level to normal Use it like Glib::Util::LogStream out ; out << Glib::Util::level_normal << "blabla" ;

LogStream& level_verbose ( LogStream a_stream  )  [friend]

sets the log level to verbose Use it lik: Glib::Util::LogStream out ; out << Glib::Util::level_verbose << "bla bla bla" ;

LogStream& timestamp ( LogStream  )  [friend]

logs a timestamp.

Basically the the current date. You use it like: Glib::Util::LogStream out ; out << Glib::Util::timestamp ;


The documentation for this class was generated from the following file:
Generated by  doxygen 1.6.2-20100208