HP-UX C SIP Stack Programmer's Guide (Novembery 2007)
354 HP-UX C SIP Stack Programmer’s Guide
Controlling the Log
/*==========================================================================*/
RvSipStackCfg stackCfg;
RvSipStackHandle hStack;
RvStatus AppInitSipStack()
{
FILE *logFile;
RvSipStackInitCfg(sizeof(stackCfg), &stackCfg));
/*Open the log file for writing*/
logFile = fopen("MyLog.txt","w");
/*Register the log function in the configuration structure*/
stackCfg.pfnPrintLogEntryEvHandler = AppLogPrintFunction;
/*Save the file pointer as a log context (optional)*/
stackCfg.logContext = logFile;
return RvSipStackConstruct(sizeof(stackCfg), &stackCfg, &hStack);
}
/*==================================================================================*/
/*The log callback function*/
void RVCALLCONV AppLogPrintFunction(
IN void* context,
IN RvSipLogFilters filter,
IN const RvChar *formattedText)
{
char data[1500];
static int line=1;
FILE *logFile = (FILE*)context;
/*Add a line number to the log*/
sprintf(data,"%8d:", line);
line ++;
/*Add the log text*/
strcat(data,formattedText);
strcat(data,"\n");
/*Write the log to the log file*/