Commit eebae20a authored by Jonathon Duerig's avatar Jonathon Duerig
Browse files

Changed logCleanup() so that it uses a switch statement rather than a series...

Changed logCleanup() so that it uses a switch statement rather than a series of if statements. Now if there are more than one flags selected, only the first one encountered will be printed as a prefix. This should make things run faster.
parent 96f7ac78
...@@ -28,51 +28,46 @@ void logCleanup(void) ...@@ -28,51 +28,46 @@ void logCleanup(void)
} }
// Print the timestamp and type of logging to the logFile. // Print the timestamp and type of logging to the logFile.
static void logPrefix(int flags) static void logPrefix(int which)
{ {
if (flags & ERROR) switch(which)
{ {
case ERROR:
fprintf(logFile, "ERROR "); fprintf(logFile, "ERROR ");
} break;
if (flags & EXCEPTION) case EXCEPTION:
{
fprintf(logFile, "EXCEPTION "); fprintf(logFile, "EXCEPTION ");
} break;
if (flags & PEER_CYCLE) case PEER_CYCLE:
{
fprintf(logFile, "PEER_CYCLE "); fprintf(logFile, "PEER_CYCLE ");
} break;
if (flags & SENSOR) case SENSOR:
{
fprintf(logFile, "SENSOR "); fprintf(logFile, "SENSOR ");
} break;
if (flags & CONNECTION_MODEL) case CONNECTION_MODEL:
{
fprintf(logFile, "CONNECTION_MODEL "); fprintf(logFile, "CONNECTION_MODEL ");
} break;
if (flags & ROBUST) case ROBUST:
{
fprintf(logFile, "ROBUST "); fprintf(logFile, "ROBUST ");
} break;
if (flags & MAIN_LOOP) case MAIN_LOOP:
{
fprintf(logFile, "MAIN_LOOP "); fprintf(logFile, "MAIN_LOOP ");
} break;
if (flags & COMMAND_INPUT) case COMMAND_INPUT:
{
fprintf(logFile, "COMMAND_INPUT "); fprintf(logFile, "COMMAND_INPUT ");
} break;
if (flags & CONNECTION) case CONNECTION:
{
fprintf(logFile, "CONNECTION "); fprintf(logFile, "CONNECTION ");
} break;
if (flags & PCAP) case PCAP:
{
fprintf(logFile, "PCAP "); fprintf(logFile, "PCAP ");
} break;
if (flags & COMMAND_OUTPUT) case COMMAND_OUTPUT:
{
fprintf(logFile, "COMMAND_OUTPUT "); fprintf(logFile, "COMMAND_OUTPUT ");
break;
default:
fprintf(logFile, "LOG_ERROR ");
break;
} }
if (logTimestamp) if (logTimestamp)
{ {
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment