VISH  0.2
Classes | Public Member Functions | Static Public Member Functions
Wizt::VLogger Class Reference

Log messages, usually for analysing the program's internal flow for debugging purposes. More...

#include </home/werner/origo/vish/ocean/plankton/VLogger.hpp>

List of all members.

Classes

Public Member Functions

Static Public Member Functions


Detailed Description

Log messages, usually for analysing the program's internal flow for debugging purposes.

While using of debuggers is helpful to trace down fatal program errors leading to segmentation faults and core dumps, debugging tools are not too effective to analyse and verify the execution flow of a program. Logical errors - in contrast to simple programming errors - are hardly determinable using runtime debuggers since they only show a certain state of a program, but not the execution history. The ability to log the program's execution flow is the more effective approach for tracing higher-level errors, especcially in a multithreaded context.

This class only provides an abstraction interface to various output facilities. Multiple clients may connect to the logging instance.

The API is intentionally as simple as possible, such that application code just needs to be instrumented with print() or printf() calls. Only required addition is the specification of a verbosity level. The higher the verbosity level, the more detailed the information is, and it is the duty of the implementation of a VLogger to display logging information only up to a certain verbosity level.

The VLogger class implements a function call stack for each thread and keep track of a context when issuing print statements. This context contains the current function name, source file name, line number and indentation level. The context may be setup automatically by some external source code instrumentation tool which inserts certain code lines. However, manual instrumentation might be more effective since there doesn't need to be a 1:1 correspondence. For instance, one specific line in a source code might emit multiple logging lines, or a function should not show up explicitely since the calling function is the one providing the relevant context.

Class Derivation Example:

class   MyLogger : public VLogger
{
        override void printmsg(const string&text,               
                               int verbosity,                   
                               int indent_spaces,               
                               const string&srcfilename,        
                               unsigned linenumber,             
                               const WeakPtr<VTask>&ThreadID,    
                               const string&funcname            
                        );


};

main()
{
RefPtr<MyLogger> MainLogger = new MyLogger();
        MainLogger->activate();
}

bool activate();

Todo:
Provide a std::ostream interface . But should be in a separate header file.

Member Function Documentation

bool Wizt::VLogger::activate ( )

Activate this VLogger object.

It must be referenced via a strongptr from some application code.

void Wizt::VLogger::print ( const string text,
int  verbosity,
int  indent_spaces,
const string srcfilename,
unsigned  linenumber,
const WeakPtr< VTask > &  ThreadID,
const string funcname 
) [static]

Verbose print function.

All arguments are broadcasted to all activated instances of VLogger objects.

Parameters:
textthe actual text to be printed
verbositythe verbosity level
indent_spaceshow many spaces to indent at the beginning of the line?
srcfilenamethe file name of the source that issues this command, usually __FILE__
linenumberthe line number of the source file, usually __LINE__
ThreadIDan identifier for the thread issuing the message
funcnamethe function context for which this function was called.
void Wizt::VLogger::printmsg ( const string text,
int  verbosity,
int  indent_spaces,
const string srcfilename,
unsigned  linenumber,
const WeakPtr< VTask > &  ThreadID,
const string funcname 
) [virtual]

Message output function.

By default, prints message on standard output.

Parameters:
textthe actual text to be printed
verbositythe verbosity level
indent_spaceshow many spaces to indent at the beginning of the line?
srcfilenamethe file name of the source that issues this command, usually __FILE__
linenumberthe line number of the source file, usually __LINE__
ThreadIDan identifier for the thread issuing the message
funcnamecurrent function (last registered for debugging)

Reimplemented in Wizt::VStreamLogger::Logger.


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