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

Reverted changes to time format. Added a 'SENSOR_DETAIL' and 'SENSOR_COMPLETE"...

Reverted changes to time format. Added a 'SENSOR_DETAIL' and 'SENSOR_COMPLETE" logging options. 'SENSOR' should now be used for high level information, 'SENSOR_DETAIL' should be used for medium level information, and 'SENSOR_COMPLETE' should be used for low-level information. If SENSOR_DETAIL logging is turned on, then SENSOR logging is also turned on. If SENSOR_COMPLETE logging is turned on, then SENSOR_DETAIL and SENSOR loggin is also turned on. All three of these levels use the 'SENSOR' prefix when outputting logging lines.
parent 90ee81ae
...@@ -20,6 +20,14 @@ void logInit(FILE * destFile, int flags, int useTimestamp) ...@@ -20,6 +20,14 @@ void logInit(FILE * destFile, int flags, int useTimestamp)
{ {
logFile = destFile; logFile = destFile;
logFlags = flags; logFlags = flags;
if ((logFlags & SENSOR_COMPLETE) != 0)
{
logFlags = logFlags | SENSOR_DETAIL | SENSOR;
}
else if ((logFlags & SENSOR_DETAIL) != 0)
{
logFlags = logFlags | SENSOR;
}
logTimestamp = useTimestamp; logTimestamp = useTimestamp;
struct timeval now; struct timeval now;
gettimeofday(&now, NULL); gettimeofday(&now, NULL);
...@@ -46,6 +54,8 @@ static void logPrefix(int which) ...@@ -46,6 +54,8 @@ static void logPrefix(int which)
case PEER_CYCLE: case PEER_CYCLE:
messageClass = "PEER_CYCLE "; messageClass = "PEER_CYCLE ";
break; break;
case SENSOR_COMPLETE:
case SENSOR_DETAIL:
case SENSOR: case SENSOR:
messageClass = "SENSOR "; messageClass = "SENSOR ";
break; break;
...@@ -78,9 +88,8 @@ static void logPrefix(int which) ...@@ -78,9 +88,8 @@ static void logPrefix(int which)
{ {
struct timeval now; struct timeval now;
gettimeofday(&now, NULL); gettimeofday(&now, NULL);
now.tv_sec -= startSeconds; fprintf(logFile, "\n%s %f: ", messageClass,
fprintf(logFile, "\n%s %u:%u: ", messageClass, (double)(now.tv_sec) + ((now.tv_usec)/1000)/1000.0);
now.tv_sec - startSeconds, (now.tv_usec)/1000);
} }
else else
{ {
......
...@@ -38,20 +38,22 @@ void logWrite(int flags, char const * format, ...); ...@@ -38,20 +38,22 @@ void logWrite(int flags, char const * format, ...);
enum LOG_TYPE enum LOG_TYPE
{ {
ERROR = 0x001, ERROR = 0x0001,
EXCEPTION = 0x002, EXCEPTION = 0x0002,
PEER_CYCLE = 0x004, PEER_CYCLE = 0x0004,
SENSOR = 0x008, SENSOR = 0x0008,
CONNECTION_MODEL = 0x010, CONNECTION_MODEL = 0x0010,
ROBUST = 0x020, ROBUST = 0x0020,
MAIN_LOOP = 0x040, MAIN_LOOP = 0x0040,
COMMAND_INPUT = 0x080, COMMAND_INPUT = 0x0080,
CONNECTION = 0x100, CONNECTION = 0x0100,
PCAP = 0x200, PCAP = 0x0200,
COMMAND_OUTPUT = 0x400, COMMAND_OUTPUT = 0x0400,
SENSOR_DETAIL = 0x0800,
SENSOR_COMPLETE = 0x1000,
// Shortcuts for common cases. // Shortcuts for common cases.
LOG_NOTHING = 0x000, LOG_NOTHING = 0x0000,
LOG_EVERYTHING = 0x7ff LOG_EVERYTHING = 0x1fff
}; };
#endif #endif
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