The log stream class. More...
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. | |
LogStream & | operator<< (LogStream &(*a_manipulator)(LogStream &)) |
log a stream manipulator | |
LogStream & | operator<< (char a_char) |
log a character | |
LogStream & | operator<< (double a_double) |
log a double | |
LogStream & | operator<< (guint an_int) |
log a guint | |
LogStream & | operator<< (int an_int) |
log an integer | |
LogStream & | operator<< (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. | |
LogStream & | write (char a_msg, const string &a_domain=GLIBMM_GENERAL_DOMAIN) |
LogStream & | write (double a_msg, const string &a_domain=GLIBMM_GENERAL_DOMAIN) |
LogStream & | write (guint a_msg, const string &a_domain=GLIBMM_GENERAL_DOMAIN) |
LogStream & | write (int a_msg, const string &a_domain=GLIBMM_GENERAL_DOMAIN) |
LogStream & | write (const Glib::ustring &a_msg, const string &a_domain=GLIBMM_GENERAL_DOMAIN) |
log a message to the stream | |
LogStream & | write (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 LogStream & | default_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 | |
LogStream & | endl (LogStream &) |
LogStream & | flush (LogStream &) |
LogStream & | level_normal (LogStream &a_stream) |
LogStream & | level_verbose (LogStream &a_stream) |
LogStream & | timestamp (LogStream &) |
The log stream class.
It features logging to cout, cerr and files. It also features log domains and log levels.
Glib::Util::LogStream::LogStream | ( | enum LogLevel | a_level = LOG_LEVEL_NORMAL , |
|
const string & | a_default_domain = GLIBMM_GENERAL_DOMAIN | |||
) |
default constructor of a LogStream.
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
static void Glib::Util::LogStream::activate | ( | bool | a_activate | ) | [static] |
activate/de-activate the logging.
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.
void Glib::Util::LogStream::enable_domain | ( | const string & | a_domain, | |
bool | a_do_enable = true | |||
) |
enable or disable logging for a domain
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
static enum StreamType Glib::Util::LogStream::get_stream_type | ( | ) | [static] |
gets the type of the instances of LogStream
static bool Glib::Util::LogStream::is_active | ( | ) | [static] |
tests wether the logging is activated or not.
bool Glib::Util::LogStream::is_domain_enabled | ( | const string & | a_domain | ) |
true
if is logging is enabled for domain a_domain
log a stream manipulator
a_manipulator | the LogStream manipulator to log |
LogStream& Glib::Util::LogStream::operator<< | ( | char | a_char | ) |
log a character
a_char | the char to log |
LogStream& Glib::Util::LogStream::operator<< | ( | double | a_double | ) |
log a double
a_double | the double to log |
LogStream& Glib::Util::LogStream::operator<< | ( | guint | an_int | ) |
log a guint
an_int | the guint to log |
LogStream& Glib::Util::LogStream::operator<< | ( | int | an_int | ) |
log an integer
an_int | the integer to log |
LogStream& Glib::Util::LogStream::operator<< | ( | const Glib::ustring & | a_string | ) |
log zero teriminated strings
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() .
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.
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.
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
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.
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
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
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. |