comparison OrthancServer/main.cpp @ 112:80ca409f232f

logging
author Sebastien Jodogne <s.jodogne@gmail.com>
date Thu, 04 Oct 2012 13:44:09 +0200
parents a6e41de88a53
children 2d96cb181f45
comparison
equal deleted inserted replaced
111:0fc3b69c0357 112:80ca409f232f
20 20
21 #include "OrthancRestApi.h" 21 #include "OrthancRestApi.h"
22 22
23 #include <stdio.h> 23 #include <stdio.h>
24 #include <glog/logging.h> 24 #include <glog/logging.h>
25 #include <boost/algorithm/string/predicate.hpp>
25 26
26 #include "../Core/HttpServer/EmbeddedResourceHttpHandler.h" 27 #include "../Core/HttpServer/EmbeddedResourceHttpHandler.h"
27 #include "../Core/HttpServer/FilesystemHttpHandler.h" 28 #include "../Core/HttpServer/FilesystemHttpHandler.h"
28 #include "../Core/HttpServer/MongooseServer.h" 29 #include "../Core/HttpServer/MongooseServer.h"
29 #include "DicomProtocol/DicomServer.h" 30 #include "DicomProtocol/DicomServer.h"
94 95
95 int main(int argc, char* argv[]) 96 int main(int argc, char* argv[])
96 { 97 {
97 // Initialize Google's logging library. 98 // Initialize Google's logging library.
98 FLAGS_logtostderr = true; 99 FLAGS_logtostderr = true;
100
101 for (int i = 1; i < argc; i++)
102 {
103 if (boost::starts_with(argv[i], "--logdir="))
104 {
105 FLAGS_logtostderr = false;
106 FLAGS_log_dir = std::string(argv[i]).substr(9);
107 }
108 }
109
99 google::InitGoogleLogging("Orthanc"); 110 google::InitGoogleLogging("Orthanc");
111
100 112
101 try 113 try
102 { 114 {
115 bool isInitialized = false;
103 if (argc >= 2) 116 if (argc >= 2)
104 { 117 {
105 OrthancInitialize(argv[1]); 118 for (int i = 1; i < argc; i++)
119 {
120 // Use the first argument that does not start with a "-" as
121 // the configuration file
122 if (argv[i][0] != '-')
123 {
124 OrthancInitialize(argv[i]);
125 isInitialized = true;
126 }
127 }
106 } 128 }
107 else 129
130 if (!isInitialized)
108 { 131 {
109 OrthancInitialize(); 132 OrthancInitialize();
110 } 133 }
111 134
112 std::string storageDirectory = GetGlobalStringParameter("StorageDirectory", "OrthancStorage"); 135 std::string storageDirectory = GetGlobalStringParameter("StorageDirectory", "OrthancStorage");