changeset 112:80ca409f232f

logging
author Sebastien Jodogne <s.jodogne@gmail.com>
date Thu, 04 Oct 2012 13:44:09 +0200
parents 0fc3b69c0357
children b00a6c68d529
files OrthancServer/main.cpp
diffstat 1 files changed, 25 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/OrthancServer/main.cpp	Thu Oct 04 12:45:24 2012 +0200
+++ b/OrthancServer/main.cpp	Thu Oct 04 13:44:09 2012 +0200
@@ -22,6 +22,7 @@
 
 #include <stdio.h>
 #include <glog/logging.h>
+#include <boost/algorithm/string/predicate.hpp>
 
 #include "../Core/HttpServer/EmbeddedResourceHttpHandler.h"
 #include "../Core/HttpServer/FilesystemHttpHandler.h"
@@ -96,15 +97,37 @@
 {
   // Initialize Google's logging library.
   FLAGS_logtostderr = true;
+  
+  for (int i = 1; i < argc; i++)
+  {
+    if (boost::starts_with(argv[i], "--logdir="))
+    {
+      FLAGS_logtostderr = false;
+      FLAGS_log_dir = std::string(argv[i]).substr(9);
+    }
+  }
+
   google::InitGoogleLogging("Orthanc");
 
+
   try
   {
+    bool isInitialized = false;
     if (argc >= 2)
     {
-      OrthancInitialize(argv[1]);
+      for (int i = 1; i < argc; i++)
+      {
+        // Use the first argument that does not start with a "-" as
+        // the configuration file
+        if (argv[i][0] != '-')
+        {
+          OrthancInitialize(argv[i]);
+          isInitialized = true;
+        }
+      }
     }
-    else
+
+    if (!isInitialized)
     {
       OrthancInitialize();
     }