improve indent to match existing
This commit is contained in:
50
servlog.c
50
servlog.c
@@ -321,8 +321,7 @@ static void SICSLogWriteFile(char *pText, OutCode eOut, struct timeval *tp)
|
|||||||
iLogUsable = OpenVerifyLogFile();
|
iLogUsable = OpenVerifyLogFile();
|
||||||
}
|
}
|
||||||
|
|
||||||
if(1 == iLogUsable)
|
if (1 == iLogUsable) {
|
||||||
{
|
|
||||||
|
|
||||||
if (iLineCount == 0)
|
if (iLineCount == 0)
|
||||||
fprintf(fLogFile, "%s: <<<open logfile>>>\n", timestamp(NULL));
|
fprintf(fLogFile, "%s: <<<open logfile>>>\n", timestamp(NULL));
|
||||||
@@ -335,7 +334,8 @@ static void SICSLogWriteFile(char *pText, OutCode eOut, struct timeval *tp)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void SICSLogWriteTime(char *pText, OutCode eOut, struct timeval *tp) {
|
void SICSLogWriteTime(char *pText, OutCode eOut, struct timeval *tp)
|
||||||
|
{
|
||||||
char buf[200];
|
char buf[200];
|
||||||
const char *cp = pText;
|
const char *cp = pText;
|
||||||
int idx = 0;
|
int idx = 0;
|
||||||
@@ -351,23 +351,19 @@ static void SICSLogWriteFile(char *pText, OutCode eOut, struct timeval *tp)
|
|||||||
buf[idx++] = '\0';
|
buf[idx++] = '\0';
|
||||||
SICSLogWriteFile(buf, eOut, tp);
|
SICSLogWriteFile(buf, eOut, tp);
|
||||||
idx = 0;
|
idx = 0;
|
||||||
}
|
} else if (*cp == '\r') {
|
||||||
else if (*cp == '\r') {
|
|
||||||
buf[idx++] = '\\';
|
buf[idx++] = '\\';
|
||||||
buf[idx++] = 'r';
|
buf[idx++] = 'r';
|
||||||
}
|
} else if (*cp == '\t') {
|
||||||
else if (*cp == '\t') {
|
|
||||||
buf[idx++] = '\\';
|
buf[idx++] = '\\';
|
||||||
buf[idx++] = 't';
|
buf[idx++] = 't';
|
||||||
}
|
} else if (*cp < ' ' || *cp > '~') {
|
||||||
else if (*cp < ' ' || *cp > '~') {
|
|
||||||
const char hex[] = "0123456789ABCDEF";
|
const char hex[] = "0123456789ABCDEF";
|
||||||
buf[idx++] = '<';
|
buf[idx++] = '<';
|
||||||
buf[idx++] = hex[(*cp >> 4) & 0xF];
|
buf[idx++] = hex[(*cp >> 4) & 0xF];
|
||||||
buf[idx++] = hex[(*cp) & 0xF];
|
buf[idx++] = hex[(*cp) & 0xF];
|
||||||
buf[idx++] = '>';
|
buf[idx++] = '>';
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
buf[idx++] = *cp;
|
buf[idx++] = *cp;
|
||||||
}
|
}
|
||||||
cp++;
|
cp++;
|
||||||
@@ -385,13 +381,16 @@ static void SICSLogWriteFile(char *pText, OutCode eOut, struct timeval *tp)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void SICSLogWrite(char *pText, OutCode eOut) {
|
void SICSLogWrite(char *pText, OutCode eOut)
|
||||||
|
{
|
||||||
struct timeval tv;
|
struct timeval tv;
|
||||||
gettimeofday(&tv, NULL);
|
gettimeofday(&tv, NULL);
|
||||||
SICSLogWriteTime(pText, eOut, &tv);
|
SICSLogWriteTime(pText, eOut, &tv);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SICSLogWriteHexTime(const char* text, int count, OutCode eOut, struct timeval *tp) {
|
void SICSLogWriteHexTime(const char *text, int count, OutCode eOut,
|
||||||
|
struct timeval *tp)
|
||||||
|
{
|
||||||
const char hex[] = "0123456789ABCDEF";
|
const char hex[] = "0123456789ABCDEF";
|
||||||
char addr[20], left[80], right[80];
|
char addr[20], left[80], right[80];
|
||||||
char *lp = left;
|
char *lp = left;
|
||||||
@@ -406,7 +405,8 @@ static void SICSLogWriteFile(char *pText, OutCode eOut, struct timeval *tp)
|
|||||||
if ((i & 0xF) == 0) {
|
if ((i & 0xF) == 0) {
|
||||||
if (i > 0) {
|
if (i > 0) {
|
||||||
char line[132];
|
char line[132];
|
||||||
snprintf(line, sizeof(line)-1, "%-6s: %-49s | %-17s |", addr, left, right);
|
snprintf(line, sizeof(line) - 1, "%-6s: %-49s | %-17s |", addr,
|
||||||
|
left, right);
|
||||||
SICSLogWriteTime(line, eOut, tp);
|
SICSLogWriteTime(line, eOut, tp);
|
||||||
}
|
}
|
||||||
snprintf(addr, sizeof(addr) - 1, "0x%04X", i);
|
snprintf(addr, sizeof(addr) - 1, "0x%04X", i);
|
||||||
@@ -419,12 +419,13 @@ static void SICSLogWriteFile(char *pText, OutCode eOut, struct timeval *tp)
|
|||||||
if (duplicates > 0) {
|
if (duplicates > 0) {
|
||||||
if (duplicates > 1) {
|
if (duplicates > 1) {
|
||||||
char line[132];
|
char line[132];
|
||||||
snprintf(line, sizeof(line)-1, "%-6s: ... (%d duplicates)", addr, duplicates);
|
snprintf(line, sizeof(line) - 1, "%-6s: ... (%d duplicates)",
|
||||||
|
addr, duplicates);
|
||||||
SICSLogWriteTime(line, eOut, tp);
|
SICSLogWriteTime(line, eOut, tp);
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
char line[132];
|
char line[132];
|
||||||
snprintf(line, sizeof(line)-1, "%-6s: %-49s | %-17s |", addr, left, right);
|
snprintf(line, sizeof(line) - 1, "%-6s: %-49s | %-17s |", addr,
|
||||||
|
left, right);
|
||||||
SICSLogWriteTime(line, eOut, tp);
|
SICSLogWriteTime(line, eOut, tp);
|
||||||
}
|
}
|
||||||
duplicates = 0;
|
duplicates = 0;
|
||||||
@@ -449,18 +450,21 @@ static void SICSLogWriteFile(char *pText, OutCode eOut, struct timeval *tp)
|
|||||||
}
|
}
|
||||||
if (i > 0) {
|
if (i > 0) {
|
||||||
char line[132];
|
char line[132];
|
||||||
snprintf(line, sizeof(line)-1, "%-6s: %-49s | %-17s |", addr, left, right);
|
snprintf(line, sizeof(line) - 1, "%-6s: %-49s | %-17s |", addr, left,
|
||||||
|
right);
|
||||||
SICSLogWriteTime(line, eOut, tp);
|
SICSLogWriteTime(line, eOut, tp);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void SICSLogWriteHex(const char* text, int count, OutCode eOut) {
|
void SICSLogWriteHex(const char *text, int count, OutCode eOut)
|
||||||
|
{
|
||||||
struct timeval tv;
|
struct timeval tv;
|
||||||
gettimeofday(&tv, NULL);
|
gettimeofday(&tv, NULL);
|
||||||
SICSLogWriteHexTime(text, count, eOut, &tv);
|
SICSLogWriteHexTime(text, count, eOut, &tv);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SICSLogTimePrintf(OutCode eOut, struct timeval *tp, const char *fmt, ...)
|
void SICSLogTimePrintf(OutCode eOut, struct timeval *tp, const char *fmt,
|
||||||
|
...)
|
||||||
{
|
{
|
||||||
va_list ap;
|
va_list ap;
|
||||||
char buf[256];
|
char buf[256];
|
||||||
@@ -519,7 +523,8 @@ static void SICSLogWriteFile(char *pText, OutCode eOut, struct timeval *tp)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Test of the logging facilities */
|
/* Test of the logging facilities */
|
||||||
int testLogCmd(SConnection *pCon, SicsInterp *pInter, void *pData, int argc, char *argv[]) {
|
int testLogCmd(SConnection *pCon, SicsInterp *pInter, void *pData,
|
||||||
|
int argc, char *argv[]) {
|
||||||
char lbuf[2048];
|
char lbuf[2048];
|
||||||
char sbuf[1000];
|
char sbuf[1000];
|
||||||
int i;
|
int i;
|
||||||
@@ -542,4 +547,3 @@ int testLogCmd(SConnection *pCon, SicsInterp *pInter, void *pData, int argc, cha
|
|||||||
return OKOK;
|
return OKOK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user