GCF LOGO VCL LOGO
GCF::LogMessageBranch Class Reference

Creates a branch in the log-message hierarchy. More...

#include <GCF3/Log>

Public Member Functions

 LogMessageBranch (const QString &context)
 
 ~LogMessageBranch ()
 

Detailed Description

This class is meant to be used on the stack for creating logical message branches for a function-context. The best way to use this class, for creating message branches, is to create an instance of this class on the 1st line of the function. After that log messages can be added to this branch by calling GCF::Log::info(), GCF::Log::warning(), GCF::Log::debug(), GCF::Log::error() or GCF::Log::fatal().

void anotherFunction();
void yetAnotherFunction();
void function()
{
GCF::LogMessageBranch branch("function() branch");
::anotherFunction();
::yetAnotherFunction();
}
void anotherFunction()
{
GCF::Log::instance()->info(GCF_DEFAULT_LOG_CONTEXT, "Simple log message");
}
void yetAnotherFunction()
{
GCF::Log::instance()->info(GCF_DEFAULT_LOG_CONTEXT, "Simple log message");
}

If no message was logged after creation on the branch, then the branch's log message will automatically be deleted when the branch object is deleted.

Note
Never create an instance of this class on the heap.

Constructor & Destructor Documentation

GCF::LogMessageBranch::LogMessageBranch ( const QString &  context)

Creates a log message branch. A new instance of GCF::LogMessage is created for representing this branch in the log-message hierarchy. The branch-message will be automatically deleted by the destructor, if no log messages were added to it.

Parameters
contexta string representing the context of the branch
GCF::LogMessageBranch::~LogMessageBranch ( )

Destructor. The branch message (created in the constructor) will automatically be destroyed, if no log-messages were added to it.