X-Git-Url: https://git.teslayout.com/public/public/public/?a=blobdiff_plain;f=example%2Fdiameter%2Flauncher%2Fmain.cpp;h=39b0a023ffe8b81eeac24f680719e445c41019b1;hb=48d4097ad5936dfc7df88cc7772333d249beb45b;hp=ab5ea0a67da757273b4aaeaef2ba27529070847f;hpb=e82da89c86bc6131727bb37498b76ce8ea3d0826;p=anna.git diff --git a/example/diameter/launcher/main.cpp b/example/diameter/launcher/main.cpp index ab5ea0a..39b0a02 100644 --- a/example/diameter/launcher/main.cpp +++ b/example/diameter/launcher/main.cpp @@ -119,7 +119,7 @@ typedef std::map < int /* message code */, codec_messages_deque* >::const_iterat 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() { @@ -397,7 +397,7 @@ class Launcher : public anna::comm::Application { 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; @@ -866,10 +866,10 @@ std::string Launcher::help() const throw() { result += "\nsendxml| 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..',"; @@ -1071,6 +1071,7 @@ int main(int argc, const char** argv) { 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 '.....xml'", false); commandLine.add("logStatisticSamples", anna::CommandLine::Argument::Optional, "Log statistics samples for the provided concept id list, over './sample..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"); @@ -1119,6 +1120,7 @@ Launcher::Launcher() : anna::comm::Application("launcher", "DiameterLauncher", " a_burstLogFile = "launcher.burst"; a_splitLog = false; a_detailedLog = false; + a_dumpLog = false; a_timeEngine = NULL; a_counterRecorder = NULL; a_counterRecorderClock = NULL; @@ -1295,6 +1297,8 @@ void Launcher::writeLogFile(const anna::diameter::codec::Message & decodedMessag title += "]"; // Build complete log: std::string log = "\n"; + std::string xml = decodedMessage.asXMLString(); + if(a_detailedLog) { anna::time::Date now; @@ -1302,7 +1306,7 @@ void Launcher::writeLogFile(const anna::diameter::codec::Message & decodedMessag 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; @@ -1310,10 +1314,25 @@ void Launcher::writeLogFile(const anna::diameter::codec::Message & decodedMessag } 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.":"answer."); + name += logExtension; + name += ".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(); @@ -1677,6 +1696,8 @@ throw(anna::RuntimeException) { 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