ProgrammedAnswers() { a_rotate = false; }
~ProgrammedAnswers() { clear(); }
- bool rotate() const const throw() { return a_rotate; }
+ bool rotate() const throw() { return a_rotate; }
void rotate(bool r) throw() { a_rotate = r; }
void clear () throw() {
anna::diameter::comm::Entity *a_entity;
std::string a_logFile, a_burstLogFile;
std::ofstream a_burstLogStream;
- bool a_splitLog, a_detailedLog;
+ bool a_splitLog, a_detailedLog, a_dumpLog;
anna::time::Date a_start_time;
anna::timex::Engine* a_timeEngine;
MyCounterRecorder *a_counterRecorder;
result += "\nsendxml|<source_file> Same as 'sendxml2e'.";
result += "\nanswerxml2e|[source_file] Answer xml source file (pathfile) for incoming request with same code from entity.";
result += "\n The answer is stored in a FIFO queue for a specific message code, then there are";
- result += "\n as many queues as different message codes have been received.";
+ result += "\n as many queues as different message codes have been programmed.";
result += "\nanswerxml2c|[source_file] Answer xml source file (pathfile) for incoming request with same code from client.";
result += "\n The answer is stored in a FIFO queue for a specific message code, then there are";
- result += "\n as many queues as different message codes have been received.";
+ result += "\n as many queues as different message codes have been programmed.";
result += "\nanswerxml|[source_file] Same as 'answerxml2c'.";
result += "\nanswerxml(2e/2c) List programmed answers (to entity/client) if no parameter provided.";
result += "\nanswerxml(2e/2c)|dump Write programmed answers (to entity/client) to file 'programmed_answer.<message code>.<sequence>',";
try {
CommandLine& commandLine(anna::CommandLine::instantiate());
// General
+ commandLine.add(NULL, anna::CommandLine::Argument::Optional, "XXXXXXXXXXXXXXXXXXXXX");
+ commandLine.add("juan,pepe,maria", anna::CommandLine::Argument::Optional, "XXXXXXXXXXXXXXXXXXXXX");
+ commandLine.add("dos,palabras", anna::CommandLine::Argument::Optional, "XXXXXXXXXXXXXXXXXXXXX");
+ commandLine.add("x,y", anna::CommandLine::Argument::Optional, "XXXXXXXXXXXXXXXXXXXXX");
+ commandLine.add("-x", anna::CommandLine::Argument::Optional, "XXXXXXXXXXXXXXXXXXXXX");
+ commandLine.add("-ooox", anna::CommandLine::Argument::Optional, "XXXXXXXXXXXXXXXXXXXXX");
+ commandLine.add("--ooox", anna::CommandLine::Argument::Optional, "XXXXXXXXXXXXXXXXXXXXX");
+ commandLine.add("--x", anna::CommandLine::Argument::Optional, "XXXXXXXXXXXXXXXXXXXXX");
+ commandLine.add("x,-y", anna::CommandLine::Argument::Optional, "XXXXXXXXXXXXXXXXXXXXX");
+ commandLine.add("x,-lly", anna::CommandLine::Argument::Optional, "XXXXXXXXXXXXXXXXXXXXX");
+ commandLine.add("bueno,a-medias", anna::CommandLine::Argument::Optional, "XXXXXXXXXXXXXXXXXXXXX");
+ commandLine.add("bueno,en-te-ro", anna::CommandLine::Argument::Optional, "XXXXXXXXXXXXXXXXXXXXX");
+ commandLine.add("b,a-ho-ra-si", anna::CommandLine::Argument::Optional, "XXXXXXXXXXXXXXXXXXXXX");
+
+
+
commandLine.add("trace", anna::CommandLine::Argument::Optional, "Trace level (emergency, alert, critical, error, warning, notice, information, debug, local0..local7)");
commandLine.add("log", anna::CommandLine::Argument::Optional, "Process log file (operations result, traffic log, etc.). By default 'launcher.log'. Empty string or \"null\" name, to disable. Warning: there is no rotation for log files (use logrotate or whatever)");
commandLine.add("splitLog", anna::CommandLine::Argument::Optional, "Splits log file (appends to log filename, extensions with the type of event: see help on startup information-level traces). No log files for code/decode and load operations are created", false);
commandLine.add("detailedLog", anna::CommandLine::Argument::Optional, "Insert detailed information at log files. Should be disabled on automatic tests. Useful on '-balance' mode to know messages flow along the sockets", false);
+ commandLine.add("dumpLog", anna::CommandLine::Argument::Optional, "Write to disk every incoming/outcoming message named as '<hop by hop>.<end to end>.<message code>.<request|answer>.xml'", false);
commandLine.add("logStatisticSamples", anna::CommandLine::Argument::Optional, "Log statistics samples for the provided concept id list, over './sample.<concept id>.csv' files. For example: \"1,2\" will log concepts 1 and 2. Reserved word \"all\" activates all registered statistics concept identifiers. That ids are shown at context dump (see help to get it).");
commandLine.add("burstLog", anna::CommandLine::Argument::Optional, "Burst operations log file. By default 'launcher.burst'. Empty string or \"null\" name, to disable. Warning: there is no rotation for log files (use logrotate or whatever). Output: dot (.) for each burst message sent/pushed, cross (x) for popped ones, and order number when multiple of 1% of burst list size, plus OTA requests when changed.");
commandLine.add("cntDir", anna::CommandLine::Argument::Optional, "Counters directory. By default is the current execution directory. Warning: a counter file will be dump per record period; take care about the possible accumulation of files");
a_burstLogFile = "launcher.burst";
a_splitLog = false;
a_detailedLog = false;
+ a_dumpLog = false;
a_timeEngine = NULL;
a_counterRecorder = NULL;
a_counterRecorderClock = NULL;
title += "]";
// Build complete log:
std::string log = "\n";
+ std::string xml = decodedMessage.asXMLString();
+
if(a_detailedLog) {
anna::time::Date now;
title += " ";
title += now.asString();
log += anna::functions::highlight(title, anna::functions::TextHighlightMode::OverAndUnderline);
- log += decodedMessage.asXMLString();
+ log += xml;
log += "\n";
log += anna::functions::highlight("Used resource");
log += detail;
} else {
log += title;
log += "\n";
- log += decodedMessage.asXMLString();
+ log += xml;
log += "\n";
}
+ if(a_dumpLog) {
+ std::string name = anna::functions::asString(decodedMessage.getHopByHop());
+ name += ".";
+ name += anna::functions::asString(decodedMessage.getEndToEnd());
+ name += ".";
+ name += anna::functions::asString(decodedMessage.getId().first);
+ name += ".";
+ name += ((decodedMessage.getId().second) ? "request.xml":"answer.xml");
+ ofstream outMsg(name.c_str(), ifstream::out | ifstream::app);
+ outMsg.write(xml.c_str(), xml.size());
+ outMsg.close();
+ }
+
// Write and close
out.write(log.c_str(), log.size());
out.close();
if(cl.exists("detailedLog")) a_detailedLog = true;
+ if(cl.exists("dumpLog")) a_dumpLog = true;
+
if(cl.exists("burstLog")) a_burstLogFile = cl.getValue("burstLog");
// Log statistics concepts