Logfiles

Chapter Updated 11/29/22


Logging

The Xbase library includes a logging module that can be turned on or off for auditing purposes. See example code below for how to use the logging routines.
#include "xbase.h"
using namespace xb;

int main( int argCnt, char **av ){
#ifdef XB_LOGGING_SUPPORT
xbString sMsg;
xbString sLogFileName;
xbXBase x;
sLogFileName = "/home/xbase/logfiles/LogFile.txt";
x.SetLogFileName( sLogFileName );
x.EnableMsgLogging();

std::cout << "Logfile is [" << x.GetLogFqFileName().Str() << "]" << std::endl;
sMsg.Sprintf( "Program [%s] initializing...", av[0] );
x.WriteLogMessage( sMsg );
std::cout << "Logging status is " << x.GetLogStatus() << std::endl;
sMsg = "A logfile message";
x.WriteLogMessage( sMsg );
x.DisableMsgLogging();
#endif /* XB_LOGGING_SUPPORT */
return 0;
}