Commit 52fe37d6 authored by Jonathon Duerig's avatar Jonathon Duerig
Browse files

Added a new more-logging option which logs everything. Removed select logging.

parent b56a7b1c
......@@ -45,7 +45,7 @@ namespace global
std::auto_ptr<CommandOutput> output;
int logFlags = LOG_EVERYTHING &
~(SENSOR_COMPLETE | SENSOR_DETAIL | SENSOR | MAIN_LOOP);
~(SENSOR_COMPLETE | SENSOR_DETAIL | SENSOR);
// The versionless pre-history was '0'. We can be backwards
// compatible by taking advantage of the fact that the old headers
......
......@@ -102,11 +102,12 @@ void processArgs(int argc, char * argv[])
{"replay-load", required_argument, NULL, 'l'},
{"replay-sensor", required_argument, NULL, 'n'},
{"less-logging", no_argument , NULL, 'L'},
{"more-logging", no_argument , NULL, 'M'},
// Required so that getopt_long can find the end of the list
{NULL, 0, NULL, 0}
};
string shortOptions = "c:p:m:i:ds:l:L";
string shortOptions = "c:p:m:i:ds:l:LM";
// Not used
int longIndex;
......@@ -282,6 +283,9 @@ void processArgs(int argc, char * argv[])
case 'L':
global::logFlags = ERROR & EXCEPTION;
break;
case 'M':
global::logFlags = LOG_EVERYTHING;
break;
case '?':
default:
usageMessage(argv[0]);
......@@ -365,26 +369,26 @@ void mainLoop(void)
{
timeUntilWrite = nextWrite->first - now;
waitPeriod = timeUntilWrite.getTimeval();
logWrite(MAIN_LOOP, "Before select, waitTime=%f",
timeUntilWrite.toDouble());
// logWrite(MAIN_LOOP, "Before select, waitTime=%f",
// timeUntilWrite.toDouble());
}
else if (nextWrite == schedule.end())
{
// otherwise we want to wait forever.
timeUntilWrite = Time();
waitPeriod = NULL;
logWrite(MAIN_LOOP, "Before select, waitTime=forever");
// logWrite(MAIN_LOOP, "Before select, waitTime=forever");
}
else
{
timeUntilWrite = Time();
waitPeriod = timeUntilWrite.getTimeval();
logWrite(MAIN_LOOP, "Before select, waitTime=zero");
// logWrite(MAIN_LOOP, "Before select, waitTime=zero");
}
int error = select(global::maxReader + 1, &readable, NULL, NULL,
// &debugTimeout);
waitPeriod);
logWrite(MAIN_LOOP, "After select");
// logWrite(MAIN_LOOP, "After select");
if (error == -1)
{
switch (errno)
......@@ -450,13 +454,15 @@ bool replayReadHeader(char * dest)
switch (version)
{
case 0:
logWrite(ERROR, "case 0");
result = replayRead(dest + Header::PREFIX_SIZE, Header::VERSION_0_SIZE);
break;
case 1:
logWrite(ERROR, "case 1");
result = replayRead(dest + Header::PREFIX_SIZE, Header::VERSION_1_SIZE);
break;
default:
logWrite(ERROR, "Unknown version: %d", version);
logWrite(ERROR, "replayReadHeader(): Unknown version: %d, type[0] %d, size[1]=%d, size[2]=%d, version[3]=%d", version, dest[0], dest[1], dest[2], dest[3]);
result = false;
break;
}
......
......@@ -12,7 +12,7 @@
#include "Command.h"
// Uncomment this to turn on the verbose input for log replay format.
// #define LOG_REPLAY_FORMAT
//#define LOG_REPLAY_FORMAT
namespace
{
......@@ -23,7 +23,7 @@ namespace
#endif
int count = 0;
int logFlag = LOG_NOTHING;
int logFlag = REPLAY;
class FileLevel
{
......@@ -144,7 +144,7 @@ char * saveHeader(char * buffer, Header const & value)
pos = saveShort(pos, value.size);
pos = saveChar(pos, value.version);
logReplay("key", 0);
if (global::CONTROL_VERSION < 1)
if (value.version < 1)
{
pos = saveBuffer(pos, value.key.id, Header::VERSION_0_SIZE);
}
......@@ -422,6 +422,7 @@ char * loadHeader(char * buffer, Header * value)
char * pos = buffer;
pos = loadChar(pos, &(value->type));
pos = loadShort(pos, &(value->size));
// logWrite(ERROR, "Value->size: %d", value->size);
pos = loadChar(pos, &(value->version));
switch(value->version)
{
......@@ -436,7 +437,7 @@ char * loadHeader(char * buffer, Header * value)
pos = loadBuffer(pos, value->key.id, ElabOrder::idSize);
break;
default:
logWrite(ERROR, "Unknown version: %d", value->version);
logWrite(ERROR, "loadHeader(): Unknown version: %d", value->version);
logWrite(ERROR, "!!!! Undefined behaviour will follow !!!!");
break;
}
......@@ -749,7 +750,7 @@ char * loadPacket(char * buffer, PacketInfo * value, struct tcp_info & kernel,
pos = loadBuffer(pos, value->elab.id, ElabOrder::idSize);
break;
default:
logWrite(ERROR, "Unknown version: %d", version);
logWrite(ERROR, "loadPacket(): Unknown version: %d", version);
logWrite(ERROR, "!!!! Undefined behaviour will follow !!!!");
break;
}
......
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