comparison OrthancServer/ServerIndex.cpp @ 108:a6e41de88a53

using glog
author Sebastien Jodogne <s.jodogne@gmail.com>
date Thu, 04 Oct 2012 11:37:56 +0200
parents a84291457608
children fe180eae201d
comparison
equal deleted inserted replaced
107:3b45473c0a73 108:a6e41de88a53
33 #include "../Core/SQLite/Transaction.h" 33 #include "../Core/SQLite/Transaction.h"
34 #include "FromDcmtkBridge.h" 34 #include "FromDcmtkBridge.h"
35 35
36 #include <boost/lexical_cast.hpp> 36 #include <boost/lexical_cast.hpp>
37 #include <stdio.h> 37 #include <stdio.h>
38 #include <glog/logging.h>
38 39
39 namespace Orthanc 40 namespace Orthanc
40 { 41 {
41 namespace Internals 42 namespace Internals
42 { 43 {
62 } 63 }
63 64
64 virtual void Compute(SQLite::FunctionContext& context) 65 virtual void Compute(SQLite::FunctionContext& context)
65 { 66 {
66 std::string fileUuid = context.GetStringValue(0); 67 std::string fileUuid = context.GetStringValue(0);
67 printf("Removing file [%s]\n", fileUuid.c_str()); 68 LOG(INFO) << "Removing file [" << fileUuid << "]";
68 if (Toolbox::IsUuid(fileUuid)) 69 if (Toolbox::IsUuid(fileUuid))
69 { 70 {
70 fileStorage_.Remove(fileUuid); 71 fileStorage_.Remove(fileUuid);
71 } 72 }
72 } 73 }
500 deletedLevels_ = (Internals::SignalDeletedLevelFunction*) 501 deletedLevels_ = (Internals::SignalDeletedLevelFunction*)
501 db_.Register(new Internals::SignalDeletedLevelFunction); 502 db_.Register(new Internals::SignalDeletedLevelFunction);
502 503
503 if (!db_.DoesTableExist("GlobalProperties")) 504 if (!db_.DoesTableExist("GlobalProperties"))
504 { 505 {
505 printf("Creating the database\n"); 506 LOG(INFO) << "Creating the database";
506 std::string query; 507 std::string query;
507 EmbeddedResources::GetFileResource(query, EmbeddedResources::PREPARE_DATABASE); 508 EmbeddedResources::GetFileResource(query, EmbeddedResources::PREPARE_DATABASE);
508 db_.Execute(query); 509 db_.Execute(query);
509 } 510 }
510 } 511 }
572 return StoreStatus_Success; 573 return StoreStatus_Success;
573 //t.Rollback(); 574 //t.Rollback();
574 } 575 }
575 catch (OrthancException& e) 576 catch (OrthancException& e)
576 { 577 {
577 std::cout << "EXCEPT2 [" << e.What() << "]" << " " << db_.GetErrorMessage() << std::endl; 578 LOG(ERROR) << "EXCEPTION [" << e.What() << "]" << " " << db_.GetErrorMessage();
578 } 579 }
579 580
580 return StoreStatus_Failure; 581 return StoreStatus_Failure;
581 } 582 }
582 583
601 } 602 }
602 603
603 switch (status) 604 switch (status)
604 { 605 {
605 case StoreStatus_Success: 606 case StoreStatus_Success:
606 std::cout << "New instance stored: " << GetTotalSize() << std::endl; 607 LOG(INFO) << "New instance stored: " << GetTotalSize() << " bytes";
607 break; 608 break;
608 609
609 case StoreStatus_AlreadyStored: 610 case StoreStatus_AlreadyStored:
610 std::cout << "Already stored" << std::endl; 611 LOG(INFO) << "Already stored";
611 break; 612 break;
612 613
613 case StoreStatus_Failure: 614 case StoreStatus_Failure:
614 std::cout << "Store failure" << std::endl; 615 LOG(INFO) << "Store failure";
615 break; 616 break;
616 } 617 }
617 618
618 return status; 619 return status;
619 } 620 }