Mercurial > hg > orthanc
comparison OrthancServer/DicomProtocol/DicomServer.cpp @ 101:428784e59dcd
trying to use log4cplus
author | jodogne |
---|---|
date | Wed, 03 Oct 2012 11:44:46 +0200 |
parents | a70bb32802ae |
children | 7593b57dc1bf |
comparison
equal
deleted
inserted
replaced
100:27dc762e3dc8 | 101:428784e59dcd |
---|---|
20 | 20 |
21 #include "DicomServer.h" | 21 #include "DicomServer.h" |
22 | 22 |
23 #include "../../Core/OrthancException.h" | 23 #include "../../Core/OrthancException.h" |
24 #include "../../Core/Toolbox.h" | 24 #include "../../Core/Toolbox.h" |
25 #include "../Internals/DcmtkLogging.h" | |
25 #include "../Internals/CommandDispatcher.h" | 26 #include "../Internals/CommandDispatcher.h" |
26 | 27 |
27 #include <boost/thread.hpp> | 28 #include <boost/thread.hpp> |
28 #include <dcmtk/dcmdata/dcdict.h> | 29 #include <dcmtk/dcmdata/dcdict.h> |
29 | 30 |
36 | 37 |
37 //std::set< | 38 //std::set< |
38 }; | 39 }; |
39 | 40 |
40 | 41 |
41 namespace Internals | |
42 { | |
43 OFLogger Logger = OFLog::getLogger("dcmtk.apps.storescp"); | |
44 } | |
45 | |
46 | |
47 void DicomServer::ServerThread(DicomServer* server) | 42 void DicomServer::ServerThread(DicomServer* server) |
48 { | 43 { |
49 /* Disable "gethostbyaddr" (which results in memory leaks) and use raw IP addresses */ | 44 /* Disable "gethostbyaddr" (which results in memory leaks) and use raw IP addresses */ |
50 dcmDisableGethostbyaddr.set(OFTrue); | 45 dcmDisableGethostbyaddr.set(OFTrue); |
51 | 46 |
52 /* make sure data dictionary is loaded */ | 47 /* make sure data dictionary is loaded */ |
53 if (!dcmDataDict.isDictionaryLoaded()) | 48 if (!dcmDataDict.isDictionaryLoaded()) |
54 { | 49 { |
55 OFLOG_WARN(Internals::Logger, "no data dictionary loaded, check environment variable: " | 50 LOG4CPP_WARN(Internals::GetLogger(), "no data dictionary loaded, check environment variable: " |
56 << DCM_DICT_ENVIRONMENT_VARIABLE); | 51 DCM_DICT_ENVIRONMENT_VARIABLE); |
57 } | 52 } |
58 | 53 |
59 /* initialize network, i.e. create an instance of T_ASC_Network*. */ | 54 /* initialize network, i.e. create an instance of T_ASC_Network*. */ |
60 T_ASC_Network *net; | 55 T_ASC_Network *net; |
61 OFCondition cond = ASC_initializeNetwork | 56 OFCondition cond = ASC_initializeNetwork |
62 (NET_ACCEPTOR, OFstatic_cast(int, server->port_), /*opt_acse_timeout*/ 30, &net); | 57 (NET_ACCEPTOR, OFstatic_cast(int, server->port_), /*opt_acse_timeout*/ 30, &net); |
63 if (cond.bad()) | 58 if (cond.bad()) |
64 { | 59 { |
65 OFString temp_str; | 60 LOG4CPP_ERROR(Internals::GetLogger(), "cannot create network: " + std::string(cond.text())); |
66 OFLOG_ERROR(Internals::Logger, "cannot create network: " << DimseCondition::dump(temp_str, cond)); | |
67 throw OrthancException("Cannot create network"); | 61 throw OrthancException("Cannot create network"); |
68 } | 62 } |
69 | 63 |
70 OFLOG_WARN(Internals::Logger, "DICOM server started"); | 64 LOG4CPP_WARN(Internals::GetLogger(), "DICOM server started"); |
71 | 65 |
72 server->started_ = true; | 66 server->started_ = true; |
73 | 67 |
74 while (server->continue_) | 68 while (server->continue_) |
75 { | 69 { |
88 IRunnableBySteps::RunUntilDone(*dispatcher); | 82 IRunnableBySteps::RunUntilDone(*dispatcher); |
89 } | 83 } |
90 } | 84 } |
91 } | 85 } |
92 | 86 |
93 OFLOG_WARN(Internals::Logger, "DICOM server stopping"); | 87 LOG4CPP_WARN(Internals::GetLogger(), "DICOM server stopping"); |
94 | 88 |
95 /* drop the network, i.e. free memory of T_ASC_Network* structure. This call */ | 89 /* drop the network, i.e. free memory of T_ASC_Network* structure. This call */ |
96 /* is the counterpart of ASC_initializeNetwork(...) which was called above. */ | 90 /* is the counterpart of ASC_initializeNetwork(...) which was called above. */ |
97 cond = ASC_dropNetwork(&net); | 91 cond = ASC_dropNetwork(&net); |
98 if (cond.bad()) | 92 if (cond.bad()) |
99 { | 93 { |
100 OFString temp_str; | 94 LOG4CPP_ERROR(Internals::GetLogger(), "Error while dropping the network: " + std::string(cond.text())); |
101 OFLOG_ERROR(Internals::Logger, DimseCondition::dump(temp_str, cond)); | |
102 } | 95 } |
103 } | 96 } |
104 | 97 |
105 | 98 |
106 DicomServer::DicomServer() : pimpl_(new PImpl) | 99 DicomServer::DicomServer() : pimpl_(new PImpl) |