Log a variable argument message to the log channel. Deprecated as the hzFuncname class is to be reviewed.
| Return Type | Function name | Arguments |
|---|---|---|
| hzEcode | hzLogger::Logr | (hzEcode,const char*,) |
Declared in file: hzProcess.h
Defined in file : hzLogger.cpp
Function Logic:
Function body:
hzEcode hzLogger::Logr (hzEcode rc)const char* va_alist,
{
// Log a variable argument message to the log channel. Deprecated as the hzFuncname class is to be reviewed.
//
// Arguments: 1) rc Intended return code of this function
// 2) va_alist Variable argument format string
//
// Returns: The supplied return code (hzEcode), in all cases
va_list ap1 ; // Variable arguments list
va_list ap2 ; // Copy of variable arguments list
const char* fmt ; // Format control string
uchar* u ; // Pointer into message buffer
uint32_t i ; // Indent counter
uint32_t nSize ; // Size of logserver client request
uint32_t nProcID ; // Caller process id
va_start(ap1, va_alist) ;
va_copy(ap2, ap1) ;
fmt = va_alist ;
// If log channel not open just return
if (!IsOpen())
return rc ;
if (m_nSessID == 0)
{
// Log channel is using a direct file
m_Lock.Lock() ;
_logrotate() ;
if (m_bVerbose)
{
for (i = m_nIndent ; i ; i--)
printf("\t") ;
printf("T%uL%02d %09lu: %04d/%02d/%02d-%02d:%02d:%02d.%06d %s:\t",
_hzGlobal_currProc->GetId(),
_hzGlobal_currProc->Level(),
_hzGlobal_currProc->FuncCallSeq(),
m_datCurr.Year(), m_datCurr.Month(), m_datCurr.Day(), m_datCurr.Hour(), m_datCurr.Min(), m_datCurr.Sec(), m_datCurr.uSec(),
_hzGlobal_currProc->GetCurrFunc()) ;
// Print supplied message
vprintf(fmt, ap1) ;
va_end(ap1) ;
fflush(stdout) ;
}
if (m_pFile)
{
for (i = m_nIndent ; i ; i--)
fprintf(m_pFile, "\t") ;
fprintf(m_pFile, "T%uL%02d %09lu: %04d/%02d/%02d-%02d:%02d:%02d.%06d %s:\t",
_hzGlobal_currProc->GetId(),
_hzGlobal_currProc->Level(),
_hzGlobal_currProc->FuncCallSeq(),
m_datCurr.Year(), m_datCurr.Month(), m_datCurr.Day(), m_datCurr.Hour(), m_datCurr.Min(), m_datCurr.Sec(), m_datCurr.uSec(),
_hzGlobal_currProc->GetCurrFunc()) ;
// Write supplied message to logfile
vfprintf(m_pFile, fmt, ap2) ;
va_end(ap2) ;
fflush(m_pFile) ;
}
m_Lock.Unlock() ;
return rc ;
}
// Log channel is using the logserver
u = (uchar*) m_cvData ;
vsprintf(m_cvData + 10,fmt,ap1) ;
nSize = 11+strlen(m_cvData + 10);
nProcID = getpid() ;
// Command
u[0]= LS_LOG ;
// Size of message
u[1]= (nSize & 0xff00)>>8;
u[2]= (nSize & 0xff);
// Session ID is 0 in this case
u[3]= (m_nSessID & 0xff0000)>>16;
u[4]= (m_nSessID & 0xff00)>>8;
u[5]= (m_nSessID & 0xff);
// Process ID
u[6]= (nProcID & 0xff00)>>24;
u[7]= (nProcID & 0xff00)>>16;
u[8]= (nProcID & 0xff00)>>8;
u[9]= (nProcID & 0xff);
// Send message
if (m_pConnection->Send(m_cvData, nSize) != E_OK)
return rc ;
if (m_pConnection->Recv(m_cvData, nSize, 64)!=E_OK)
return rc ;
// if (m_cvData[0] == LS_OK)
return rc ;
}