Improvements from anna fork
[anna.git] / example / diameter / launcher / main.cpp
index 6f2a653..ca439a6 100644 (file)
 // Process
 #include <Launcher.hpp>
 
+// To calculate the current working directory and get an absolute path for traces:
+#include <limits.h>
+#include <unistd.h>
+
 
 int main(int argc, const char** argv) {
   anna::Logger::setLevel(anna::Logger::Warning);
-  anna::Logger::initialize("launcher", new TraceWriter("launcher.trace", 2048000));
+
+  // Current working directory and absolute trace path file:
+  char c_cwd[ PATH_MAX ];
+  std::string trace_file;
+  if (getcwd(c_cwd, sizeof(c_cwd)) != NULL) {
+    trace_file = c_cwd;
+    trace_file += "/launcher.trace";
+  } else {
+     perror("getcwd() error");
+     return 1;
+  }
+
+  anna::Logger::initialize("launcher", new TraceWriter(trace_file.c_str(), 2048000));
   anna::time::functions::initialize(); // before application instantiation (it have a anna::time object)
   anna::time::functions::setControlPoint(); // start control point (application lifetime)
   Launcher app;