CTBCAFLog

From TBwiki
Jump to: navigation, search

The class CTBCAFLog automatically writes calls to "LogTrace" function (which the CAF library itself uses to log useful information) to log files. It also manages log files rotation and zipping.

This module should be initialized through the GlobalSetParams function. Parameters for this module are contained in class CTBCAFLogParams

Please refer to documentation in the C++ header files for class CTBCAFLogParams to know more about available parameters.

Example usage

TBX_RESULT MyApplication::Init()
{
	TBX_RESULT			Result = TBX_RESULT_OK;
	CTBCAFGlobalsParams	CafGlobalParams;
	CTBCAFLogParams		CafLogParams;

	// Set the parameters you want
	CafLogParams.mstrApplicationName	= "MyApplication";
	CafLogParams.mstrLogFilePath		= "";	// In working directory, automatically based on application name and date
	CafLogParams.mfUseXMLPrint			= TBX_FALSE;
	// (other parameters are generally left to default values)

	CafGlobalParams.mpLogParams			= &CafLogParams;
	// CafGlobalParams.mpCommParams		= [your paramters...]
	// CafGlobalParams.mpCliParams		= [your paramters...]
	// etc...

	Result = TBCAF::GlobalSetParam( &CafGlobalParams );

	return Result;
}

TBX_RESULT MyApplication::UnInit()
{
	TBX_RESULT			Result = TBX_RESULT_OK;
	CTBCAFGlobalsParams		EmptyGlobalParams;

	// Terminate all CAF modules
	Result = TBCAF::GlobalSetParam( &EmptyGlobalParams );

	return Result;
}
Personal tools