version 1.35, 1996/11/21 19:43:48
|
version 1.36, 1996/11/22 16:47:01
|
Line 111 PUBLIC int HTWatch(int id, void * obj, c
|
Line 111 PUBLIC int HTWatch(int id, void * obj, c
|
return vfprintf(stderr, fmt, pArgs); |
return vfprintf(stderr, fmt, pArgs); |
} |
} |
|
|
|
#define LOG_BUFF_SIZE 65536 |
|
int LogFile = 2; |
|
char * LogBuff = NULL; |
|
size_t LogLen = 0; |
|
|
|
PUBLIC int HTWatch_logOpen (char *ident, int option, int facility) |
|
{ |
|
#ifdef USE_SYSLOG |
|
openlog(ident, option, facility); |
|
#else /* USE_SYSLOG */ |
|
#if 0 |
|
if ((LogFile = open("HTRobot.log", O_CREAT|O_TRUNC)) == -1) |
|
return HT_ERROR; |
|
close(LogFile); |
|
#endif |
|
if ((LogBuff = (char *) HT_MALLOC(LOG_BUFF_SIZE)) == NULL) |
|
HT_OUTOFMEM("HTWatch_logOpen"); |
|
LogLen = 0; |
|
#endif /* !USE_SYSLOG */ |
|
return HT_OK; |
|
} |
|
|
|
PRIVATE int HTWatch_logFlush(void) |
|
{ |
|
if ((LogFile = open("HTRobot.log", O_APPEND)) == -1) |
|
return HT_ERROR; |
|
write(LogFile, LogBuff, LogLen); |
|
LogLen = 0; |
|
close(LogFile); |
|
return HT_OK; |
|
} |
|
|
|
PRIVATE int HTWatch_logAdd(char * buf, size_t len) |
|
{ |
|
/* |
|
** Dump everything that won't fit in buffer |
|
*/ |
|
while (len + LogLen > LOG_BUFF_SIZE) { |
|
size_t toWrite = LOG_BUFF_SIZE-LogLen; |
|
memcpy(LogBuff+LogLen, buf, toWrite); |
|
HTWatch_logFlush(); |
|
buf += toWrite; |
|
len -= toWrite; |
|
} |
|
memcpy(LogBuff+LogLen, buf, len); |
|
LogLen += len; |
|
return HT_OK; |
|
} |
|
|
|
PUBLIC void HTWatch_logClose (void) |
|
{ |
|
#ifdef USE_SYSLOG |
|
closelog(); |
|
#else /* USE_SYSLOG */ |
|
if (LogLen) |
|
HTWatch_logFlush(); |
|
if (LogFile > 2) |
|
close(LogFile); |
|
if (LogBuff != NULL) |
|
HT_FREE(LogBuff); |
|
#endif /* !USE_SYSLOG */ |
|
} |
|
|
|
PUBLIC int HTWatch_logData (char * data, size_t len, const char * fmt, ...) |
|
{ |
|
char buff[8200]; |
|
va_list pArgs; |
|
char * tptr; |
|
time_t now; |
|
int ret; |
|
va_start(pArgs, fmt); |
|
ret = vsprintf(buff, fmt, pArgs); |
|
#ifdef USE_SYSLOG |
|
syslog(LOG_DEBUG, "%s\n", buff); |
|
if (len > 8192) |
|
len = 8192; |
|
strncpy(buff, data, len); |
|
buff[len] = 0; |
|
syslog(LOG_DEBUG, "%s\n", buff); |
|
#else /* USE_SYSLOG */ |
|
time(&now); |
|
tptr = ctime(&now); |
|
HTWatch_logAdd(tptr, strlen(tptr)); |
|
HTWatch_logAdd(buff, ret); |
|
HTWatch_logAdd("\n", 1); |
|
HTWatch_logAdd(data, len); |
|
#endif /* !USE_SYSLOG */ |
|
return ret; |
|
} |
|
|
/* Standard (non-error) Output |
/* Standard (non-error) Output |
** --------------------------- |
** --------------------------- |
*/ |
*/ |
Line 260 PRIVATE void Cleanup (Robot * me, int st
|
Line 350 PRIVATE void Cleanup (Robot * me, int st
|
{ |
{ |
Robot_delete(me); |
Robot_delete(me); |
HTProfile_delete(); |
HTProfile_delete(); |
|
HTWatch_logClose(); |
#ifdef VMS |
#ifdef VMS |
exit(status ? status : 1); |
exit(status ? status : 1); |
#else |
#else |
Line 478 int main (int argc, char ** argv)
|
Line 569 int main (int argc, char ** argv)
|
argc=ccommand(&argv); |
argc=ccommand(&argv); |
#endif |
#endif |
|
|
|
HTWatch_logOpen("HTRobot", LOG_NDELAY, LOG_USER); |
/* Initiate W3C Reference Library with a robot profile */ |
/* Initiate W3C Reference Library with a robot profile */ |
HTProfile_newRobot(APP_NAME, APP_VERSION); |
HTProfile_newRobot(APP_NAME, APP_VERSION); |
|
|