Added SICSLogWriteTime to allow timestamp to be supplied for deferred logging
r2366 | dcl | 2008-02-21 15:02:15 +1100 (Thu, 21 Feb 2008) | 2 lines
This commit is contained in:
20
servlog.c
20
servlog.c
@@ -53,6 +53,7 @@
|
||||
#include <assert.h>
|
||||
#include <string.h>
|
||||
#include <ctype.h>
|
||||
#include <sys/time.h>
|
||||
#include "ifile.h"
|
||||
#include "conman.h"
|
||||
#include "servlog.h"
|
||||
@@ -223,11 +224,14 @@
|
||||
return 1;
|
||||
}
|
||||
|
||||
static const char* timestamp(void) {
|
||||
static const char* timestamp(struct timeval *tp) {
|
||||
static char ts[80];
|
||||
int hh, mm, ss;
|
||||
struct timeval tv;
|
||||
gettimeofday(&tv, NULL);
|
||||
if (tp)
|
||||
tv = *tp;
|
||||
else
|
||||
gettimeofday(&tv, NULL);
|
||||
hh = (tv.tv_sec / 3600) % 24;
|
||||
mm = (tv.tv_sec / 60) % 60;
|
||||
ss = tv.tv_sec % 60;
|
||||
@@ -275,7 +279,7 @@ static const char* timestamp(void) {
|
||||
}
|
||||
|
||||
/*---------------------------------------------------------------------------*/
|
||||
void SICSLogWrite(char *pText, OutCode eOut)
|
||||
void SICSLogWriteTime(char *pText, OutCode eOut, struct timeval *tp)
|
||||
{
|
||||
pCaptureEntry pCurrent;
|
||||
int text_len;
|
||||
@@ -314,7 +318,7 @@ static const char* timestamp(void) {
|
||||
/* switch file if too many lines */
|
||||
if(iLineCount >= MAXLOG)
|
||||
{
|
||||
fprintf(fLogFile,"%s: <<<close logfile>>>\n", timestamp());
|
||||
fprintf(fLogFile,"%s: <<<close logfile>>>\n", timestamp(NULL));
|
||||
fclose(fLogFile);
|
||||
fLogFile = NULL;
|
||||
iFile++;
|
||||
@@ -330,8 +334,8 @@ static const char* timestamp(void) {
|
||||
{
|
||||
|
||||
if (iLineCount == 0)
|
||||
fprintf(fLogFile,"%s: <<<open logfile>>>\n", timestamp());
|
||||
fprintf(fLogFile,"%s: ", timestamp());
|
||||
fprintf(fLogFile,"%s: <<<open logfile>>>\n", timestamp(NULL));
|
||||
fprintf(fLogFile,"%s: ", timestamp(tp));
|
||||
fprintf(fLogFile,"%s", pText);
|
||||
if (text_len < 1 || pText[text_len - 1] != '\n')
|
||||
fprintf(fLogFile,"\n");
|
||||
@@ -354,3 +358,7 @@ static const char* timestamp(void) {
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
void SICSLogWrite(char *pText, OutCode eOut) {
|
||||
SICSLogWriteTime(pText, eOut, NULL);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user