Commit ceee0c13 authored by Jonathon Duerig's avatar Jonathon Duerig

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)
{
logFile = destFile;
logFlags = flags;
if ((logFlags & SENSOR_COMPLETE) != 0)
{
logFlags = logFlags | SENSOR_DETAIL | SENSOR;
}
else if ((logFlags & SENSOR_DETAIL) != 0)
{
logFlags = logFlags | SENSOR;
}
logTimestamp = useTimestamp;
struct timeval now;
gettimeofday(&now, NULL);
......@@ -46,6 +54,8 @@ static void logPrefix(int which)
case PEER_CYCLE:
messageClass = "PEER_CYCLE ";
break;
case SENSOR_COMPLETE:
case SENSOR_DETAIL:
case SENSOR:
messageClass = "SENSOR ";
break;
......@@ -78,9 +88,8 @@ static void logPrefix(int which)
{
struct timeval now;
gettimeofday(&now, NULL);
now.tv_sec -= startSeconds;
fprintf(logFile, "\n%s %u:%u: ", messageClass,
now.tv_sec - startSeconds, (now.tv_usec)/1000);
fprintf(logFile, "\n%s %f: ", messageClass,
(double)(now.tv_sec) + ((now.tv_usec)/1000)/1000.0);
}
else
{
......
......@@ -38,20 +38,22 @@ void logWrite(int flags, char const * format, ...);
enum LOG_TYPE
{
ERROR = 0x001,
EXCEPTION = 0x002,
PEER_CYCLE = 0x004,
SENSOR = 0x008,
CONNECTION_MODEL = 0x010,
ROBUST = 0x020,
MAIN_LOOP = 0x040,
COMMAND_INPUT = 0x080,
CONNECTION = 0x100,
PCAP = 0x200,
COMMAND_OUTPUT = 0x400,
ERROR = 0x0001,
EXCEPTION = 0x0002,
PEER_CYCLE = 0x0004,
SENSOR = 0x0008,
CONNECTION_MODEL = 0x0010,
ROBUST = 0x0020,
MAIN_LOOP = 0x0040,
COMMAND_INPUT = 0x0080,
CONNECTION = 0x0100,
PCAP = 0x0200,
COMMAND_OUTPUT = 0x0400,
SENSOR_DETAIL = 0x0800,
SENSOR_COMPLETE = 0x1000,
// Shortcuts for common cases.
LOG_NOTHING = 0x000,
LOG_EVERYTHING = 0x7ff
LOG_NOTHING = 0x0000,
LOG_EVERYTHING = 0x1fff
};
#endif
Markdown is supported
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