changeset 108:a6e41de88a53

using glog
author Sebastien Jodogne <s.jodogne@gmail.com>
date Thu, 04 Oct 2012 11:37:56 +0200
parents 3b45473c0a73
children 8c0a5666b05f
files Core/HttpServer/MongooseServer.cpp OrthancServer/OrthancInitialization.cpp OrthancServer/ServerIndex.cpp OrthancServer/main.cpp
diffstat 4 files changed, 19 insertions(+), 16 deletions(-) [+]
line wrap: on
line diff
--- a/Core/HttpServer/MongooseServer.cpp	Thu Oct 04 11:22:20 2012 +0200
+++ b/Core/HttpServer/MongooseServer.cpp	Thu Oct 04 11:37:56 2012 +0200
@@ -30,6 +30,7 @@
 #include <string.h>
 #include <stdio.h>
 #include <boost/thread.hpp>
+#include <glog/logging.h>
 
 #include "../OrthancException.h"
 #include "../ChunkedBuffer.h"
@@ -530,7 +531,7 @@
         }
         catch (OrthancException& e)
         {
-          std::cerr << "MongooseServer Exception [" << e.What() << "]" << std::endl;
+          LOG(ERROR) << "MongooseServer Exception [" << e.What() << "]";
           output.SendHeader(Orthanc_HttpStatus_500_InternalServerError);        
         }
       }
--- a/OrthancServer/OrthancInitialization.cpp	Thu Oct 04 11:22:20 2012 +0200
+++ b/OrthancServer/OrthancInitialization.cpp	Thu Oct 04 11:37:56 2012 +0200
@@ -27,6 +27,7 @@
 #include <boost/filesystem.hpp>
 #include <curl/curl.h>
 #include <boost/thread.hpp>
+#include <glog/logging.h>
 
 namespace Orthanc
 {
@@ -45,7 +46,7 @@
     if (configurationFile)
     {
       Toolbox::ReadFile(content, configurationFile);
-      printf("Using the configuration from: [%s]\n", configurationFile);
+      LOG(INFO) << "Using the configuration from: " << configurationFile;
     }
     else
     {
@@ -61,18 +62,18 @@
         p /= CONFIGURATION_FILE;
           
         Toolbox::ReadFile(content, p.string());
-        printf("Using the configuration from: [%s]\n", p.string().c_str());
+        LOG(INFO) << "Using the configuration from: " << p.string();
       }
       catch (OrthancException&)
       {
         // No configuration file found, give up with empty configuration
-        printf("Using the default Orthanc configuration\n");
+        LOG(INFO) << "Using the default Orthanc configuration";
         return;
       }
 
 #elif ORTHANC_STANDALONE == 1
       // No default path for the standalone configuration
-      printf("Using the default Orthanc configuration\n");
+      LOG(INFO) << "Using the default Orthanc configuration";
       return;
 
 #else
@@ -84,12 +85,12 @@
         p /= "Resources";
         p /= CONFIGURATION_FILE;
         Toolbox::ReadFile(content, p.string());
-        printf("Using the configuration from: [%s]\n", p.string().c_str());
+        LOG(INFO) << "Using the configuration from: " << p.string();
       }
       catch (OrthancException&)
       {
         // No configuration file found, give up with empty configuration
-        printf("Using the default Orthanc configuration\n");
+        LOG(INFO) << "Using the default Orthanc configuration";
         return;
       }
 #endif
--- a/OrthancServer/ServerIndex.cpp	Thu Oct 04 11:22:20 2012 +0200
+++ b/OrthancServer/ServerIndex.cpp	Thu Oct 04 11:37:56 2012 +0200
@@ -35,6 +35,7 @@
 
 #include <boost/lexical_cast.hpp>
 #include <stdio.h>
+#include <glog/logging.h>
 
 namespace Orthanc
 {
@@ -64,7 +65,7 @@
       virtual void Compute(SQLite::FunctionContext& context)
       {
         std::string fileUuid = context.GetStringValue(0);
-        printf("Removing file [%s]\n", fileUuid.c_str());
+        LOG(INFO) << "Removing file [" << fileUuid << "]";
         if (Toolbox::IsUuid(fileUuid))
         {
           fileStorage_.Remove(fileUuid);
@@ -502,7 +503,7 @@
 
     if (!db_.DoesTableExist("GlobalProperties"))
     {
-      printf("Creating the database\n");
+      LOG(INFO) << "Creating the database";
       std::string query;
       EmbeddedResources::GetFileResource(query, EmbeddedResources::PREPARE_DATABASE);
       db_.Execute(query);
@@ -574,7 +575,7 @@
     }
     catch (OrthancException& e)
     {
-      std::cout << "EXCEPT2 [" << e.What() << "]" << " " << db_.GetErrorMessage() << std::endl;  
+      LOG(ERROR) << "EXCEPTION [" << e.What() << "]" << " " << db_.GetErrorMessage();  
     }
 
     return StoreStatus_Failure;
@@ -603,15 +604,15 @@
     switch (status)
     {
     case StoreStatus_Success:
-      std::cout << "New instance stored: " << GetTotalSize() << std::endl;
+      LOG(INFO) << "New instance stored: " << GetTotalSize() << " bytes";
       break;
 
     case StoreStatus_AlreadyStored:
-      std::cout << "Already stored" << std::endl;
+      LOG(INFO) << "Already stored";
       break;
 
     case StoreStatus_Failure:
-      std::cout << "Store failure" << std::endl;
+      LOG(INFO) << "Store failure";
       break;
     }
 
--- a/OrthancServer/main.cpp	Thu Oct 04 11:22:20 2012 +0200
+++ b/OrthancServer/main.cpp	Thu Oct 04 11:37:56 2012 +0200
@@ -152,18 +152,18 @@
       httpServer.Start();
       dicomServer.Start();
 
-      printf("The server has started\n");
+      LOG(INFO) << "The server has started";
       Toolbox::ServerBarrier();
 
       // Stop
-      printf("Finishing\n");
+      LOG(INFO) << "The server is stopping";
     }
 
     storeScp.Done();
   }
   catch (OrthancException& e)
   {
-    std::cout << "EXCEPT [" << e.What() << "]" << std::endl;
+    LOG(ERROR) << "EXCEPTION [" << e.What() << "]";
   }
 
   OrthancFinalize();