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 <assert.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
|
#include <sys/time.h>
|
||||||
#include "ifile.h"
|
#include "ifile.h"
|
||||||
#include "conman.h"
|
#include "conman.h"
|
||||||
#include "servlog.h"
|
#include "servlog.h"
|
||||||
@@ -223,11 +224,14 @@
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
static const char* timestamp(void) {
|
static const char* timestamp(struct timeval *tp) {
|
||||||
static char ts[80];
|
static char ts[80];
|
||||||
int hh, mm, ss;
|
int hh, mm, ss;
|
||||||
struct timeval tv;
|
struct timeval tv;
|
||||||
gettimeofday(&tv, NULL);
|
if (tp)
|
||||||
|
tv = *tp;
|
||||||
|
else
|
||||||
|
gettimeofday(&tv, NULL);
|
||||||
hh = (tv.tv_sec / 3600) % 24;
|
hh = (tv.tv_sec / 3600) % 24;
|
||||||
mm = (tv.tv_sec / 60) % 60;
|
mm = (tv.tv_sec / 60) % 60;
|
||||||
ss = tv.tv_sec % 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;
|
pCaptureEntry pCurrent;
|
||||||
int text_len;
|
int text_len;
|
||||||
@@ -314,7 +318,7 @@ static const char* timestamp(void) {
|
|||||||
/* switch file if too many lines */
|
/* switch file if too many lines */
|
||||||
if(iLineCount >= MAXLOG)
|
if(iLineCount >= MAXLOG)
|
||||||
{
|
{
|
||||||
fprintf(fLogFile,"%s: <<<close logfile>>>\n", timestamp());
|
fprintf(fLogFile,"%s: <<<close logfile>>>\n", timestamp(NULL));
|
||||||
fclose(fLogFile);
|
fclose(fLogFile);
|
||||||
fLogFile = NULL;
|
fLogFile = NULL;
|
||||||
iFile++;
|
iFile++;
|
||||||
@@ -330,8 +334,8 @@ static const char* timestamp(void) {
|
|||||||
{
|
{
|
||||||
|
|
||||||
if (iLineCount == 0)
|
if (iLineCount == 0)
|
||||||
fprintf(fLogFile,"%s: <<<open logfile>>>\n", timestamp());
|
fprintf(fLogFile,"%s: <<<open logfile>>>\n", timestamp(NULL));
|
||||||
fprintf(fLogFile,"%s: ", timestamp());
|
fprintf(fLogFile,"%s: ", timestamp(tp));
|
||||||
fprintf(fLogFile,"%s", pText);
|
fprintf(fLogFile,"%s", pText);
|
||||||
if (text_len < 1 || pText[text_len - 1] != '\n')
|
if (text_len < 1 || pText[text_len - 1] != '\n')
|
||||||
fprintf(fLogFile,"\n");
|
fprintf(fLogFile,"\n");
|
||||||
@@ -354,3 +358,7 @@ static const char* timestamp(void) {
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SICSLogWrite(char *pText, OutCode eOut) {
|
||||||
|
SICSLogWriteTime(pText, eOut, NULL);
|
||||||
|
}
|
||||||
|
|||||||
@@ -16,6 +16,7 @@
|
|||||||
#define SICSLOG
|
#define SICSLOG
|
||||||
#include "Scommon.h"
|
#include "Scommon.h"
|
||||||
void SICSLogWrite(char *ptext, OutCode eOut );
|
void SICSLogWrite(char *ptext, OutCode eOut );
|
||||||
|
void SICSLogWriteTime(char *ptext, OutCode eOut, struct timeval *tp );
|
||||||
int KillCapture(SConnection *pCon);
|
int KillCapture(SConnection *pCon);
|
||||||
|
|
||||||
int LogCapture(SConnection *pCon, SicsInterp *pInter, void *pData,
|
int LogCapture(SConnection *pCon, SicsInterp *pInter, void *pData,
|
||||||
|
|||||||
Reference in New Issue
Block a user