changeset 4287:5a3374b6e707

using CLOG in Orthanc DICOM handlers
author Sebastien Jodogne <s.jodogne@gmail.com>
date Wed, 04 Nov 2020 17:48:11 +0100
parents 526bd8bad850
children 5b254bd435d3
files OrthancServer/Sources/OrthancFindRequestHandler.cpp OrthancServer/Sources/OrthancGetRequestHandler.cpp OrthancServer/Sources/OrthancMoveRequestHandler.cpp
diffstat 3 files changed, 53 insertions(+), 51 deletions(-) [+]
line wrap: on
line diff
--- a/OrthancServer/Sources/OrthancFindRequestHandler.cpp	Wed Nov 04 17:40:25 2020 +0100
+++ b/OrthancServer/Sources/OrthancFindRequestHandler.cpp	Wed Nov 04 17:48:11 2020 +0100
@@ -368,7 +368,7 @@
     if (result.GetSize() == 0 &&
         sequencesToReturn.empty())
     {
-      LOG(WARNING) << "The C-FIND request does not return any DICOM tag";
+      CLOG(WARNING, DICOM) << "The C-FIND request does not return any DICOM tag";
     }
     else if (sequencesToReturn.empty())
     {
@@ -376,7 +376,7 @@
     }
     else if (dicomAsJson == NULL)
     {
-      LOG(WARNING) << "C-FIND query requesting a sequence, but reading JSON from disk is disabled";
+      CLOG(WARNING, DICOM) << "C-FIND query requesting a sequence, but reading JSON from disk is disabled";
       answers.Add(result);
     }
     else
@@ -631,24 +631,24 @@
 
 
     DicomArray query(*filteredInput);
-    LOG(INFO) << "DICOM C-Find request at level: " << EnumerationToString(level);
+    CLOG(INFO, DICOM) << "DICOM C-Find request at level: " << EnumerationToString(level);
 
     for (size_t i = 0; i < query.GetSize(); i++)
     {
       if (!query.GetElement(i).GetValue().IsNull())
       {
-        LOG(INFO) << "  " << query.GetElement(i).GetTag()
-                  << "  " << FromDcmtkBridge::GetTagName(query.GetElement(i))
-                  << " = " << query.GetElement(i).GetValue().GetContent();
+        CLOG(INFO, DICOM) << "  " << query.GetElement(i).GetTag()
+                          << "  " << FromDcmtkBridge::GetTagName(query.GetElement(i))
+                          << " = " << query.GetElement(i).GetValue().GetContent();
       }
     }
 
     for (std::list<DicomTag>::const_iterator it = sequencesToReturn.begin();
          it != sequencesToReturn.end(); ++it)
     {
-      LOG(INFO) << "  (" << it->Format()
-                << ")  " << FromDcmtkBridge::GetTagName(*it, "")
-                << " : sequence tag whose content will be copied";
+      CLOG(INFO, DICOM) << "  (" << it->Format()
+                        << ")  " << FromDcmtkBridge::GetTagName(*it, "")
+                        << " : sequence tag whose content will be copied";
     }
 
     // collect the private creators from the query itself
@@ -710,8 +710,9 @@
       }
       else
       {
-        LOG(INFO) << "Because of a patch for the manufacturer of the remote modality, " 
-                  << "ignoring constraint on tag (" << tag.Format() << ") " << FromDcmtkBridge::GetTagName(element);
+        CLOG(INFO, DICOM) << "Because of a patch for the manufacturer of the remote modality, " 
+                          << "ignoring constraint on tag (" << tag.Format() << ") "
+                          << FromDcmtkBridge::GetTagName(element);
       }
     }
 
--- a/OrthancServer/Sources/OrthancGetRequestHandler.cpp	Wed Nov 04 17:40:25 2020 +0100
+++ b/OrthancServer/Sources/OrthancGetRequestHandler.cpp	Wed Nov 04 17:48:11 2020 +0100
@@ -160,8 +160,8 @@
         }
         else
         {
-          LOG(WARNING) << "C-GET: Unknown transfer syntax received: "
-                       << pc->acceptedTransferSyntax;
+          CLOG(WARNING, DICOM) << "C-GET: Unknown transfer syntax received: "
+                               << pc->acceptedTransferSyntax;
         }
             
         pc = (DUL_PRESENTATIONCONTEXT*) LST_Next(l);
@@ -258,9 +258,9 @@
     }
     else
     {
-      LOG(INFO) << "C-GET SCP selected transfer syntax " << GetTransferSyntaxUid(selectedSyntax)
-                << ", for source instance with SOP class " << sopClassUid
-                << " and transfer syntax " << GetTransferSyntaxUid(sourceSyntax);
+      CLOG(INFO, DICOM) << "C-GET SCP selected transfer syntax " << GetTransferSyntaxUid(selectedSyntax)
+                        << ", for source instance with SOP class " << sopClassUid
+                        << " and transfer syntax " << GetTransferSyntaxUid(sourceSyntax);
 
       // make sure that we can send images in this presentation context
       T_ASC_PresentationContext pc;
@@ -295,8 +295,8 @@
     T_DIMSE_C_StoreRSP rsp;
     memset(&rsp, 0, sizeof(rsp));
 
-    LOG(INFO) << "Store SCU RQ: MsgID " << msgId << ", ("
-              << dcmSOPClassUIDToModality(sopClassUid.c_str(), "OT") << ")";
+    CLOG(INFO, DICOM) << "Store SCU RQ: MsgID " << msgId << ", ("
+                      << dcmSOPClassUIDToModality(sopClassUid.c_str(), "OT") << ")";
     
     T_DIMSE_DetectedCancelParameters cancelParameters;
     memset(&cancelParameters, 0, sizeof(cancelParameters));
@@ -361,7 +361,7 @@
       
       if (cancelParameters.cancelEncountered)
       {
-        LOG(INFO) << "C-GET SCP: Received C-Cancel RQ";
+        CLOG(INFO, DICOM) << "C-GET SCP: Received C-Cancel RQ";
         isContinue = false;
       }
       else if (rsp.DimseStatus == STATUS_Success)
@@ -374,8 +374,8 @@
       {
         // a warning status message
         warningCount_++;
-        LOG(ERROR) << "C-GET SCP: Store Warning: Response Status: "
-                   << DU_cstoreStatusString(rsp.DimseStatus);
+        CLOG(ERROR, DICOM) << "C-GET SCP: Store Warning: Response Status: "
+                           << DU_cstoreStatusString(rsp.DimseStatus);
         isContinue = true;
       }
       else
@@ -383,8 +383,8 @@
         failedCount_++;
         AddFailedUIDInstance(sopInstanceUid);
         // print a status message
-        LOG(ERROR) << "C-GET SCP: Store Failed: Response Status: "
-                   << DU_cstoreStatusString(rsp.DimseStatus);
+        CLOG(ERROR, DICOM) << "C-GET SCP: Store Failed: Response Status: "
+                           << DU_cstoreStatusString(rsp.DimseStatus);
         isContinue = true;
       }
     }
@@ -393,7 +393,8 @@
       failedCount_++;
       AddFailedUIDInstance(sopInstanceUid);
       OFString temp_str;
-      LOG(ERROR) << "C-GET SCP: storeSCU: Store Request Failed: " << DimseCondition::dump(temp_str, cond);
+      CLOG(ERROR, DICOM) << "C-GET SCP: storeSCU: Store Request Failed: "
+                         << DimseCondition::dump(temp_str, cond);
       isContinue = true;
     }
     
@@ -405,7 +406,7 @@
       DcmObject::PrintHelper obj(*stDetail);
       obj.dcmobj_.print(s);
 
-      LOG(INFO) << "  Status Detail: " << s.str();
+      CLOG(INFO, DICOM) << "  Status Detail: " << s.str();
     }
     
     return isContinue;
@@ -463,8 +464,8 @@
 
         if (tmp.empty())
         {
-          LOG(ERROR) << "C-GET: Cannot locate resource \"" << tokens[i]
-                     << "\" at the " << EnumerationToString(level) << " level";
+          CLOG(ERROR, DICOM) << "C-GET: Cannot locate resource \"" << tokens[i]
+                             << "\" at the " << EnumerationToString(level) << " level";
           return false;
         }
         else
@@ -481,15 +482,15 @@
   }
 
 
-    OrthancGetRequestHandler::OrthancGetRequestHandler(ServerContext& context) :
-      context_(context)
-    {
-      position_ = 0;
-      completedCount_  = 0;
-      warningCount_ = 0;
-      failedCount_ = 0;
-      timeout_ = 0;
-    }
+  OrthancGetRequestHandler::OrthancGetRequestHandler(ServerContext& context) :
+    context_(context)
+  {
+    position_ = 0;
+    completedCount_  = 0;
+    warningCount_ = 0;
+    failedCount_ = 0;
+    timeout_ = 0;
+  }
 
 
   bool OrthancGetRequestHandler::Handle(const DicomMap& input,
@@ -500,7 +501,7 @@
   {
     MetricsRegistry::Timer timer(context_.GetMetricsRegistry(), "orthanc_get_scp_duration_ms");
 
-    LOG(WARNING) << "C-GET-SCU request received from AET \"" << originatorAet << "\"";
+    CLOG(WARNING, DICOM) << "C-GET-SCU request received from AET \"" << originatorAet << "\"";
 
     {
       DicomArray query(input);
@@ -508,9 +509,9 @@
       {
         if (!query.GetElement(i).GetValue().IsNull())
         {
-          LOG(INFO) << "  " << query.GetElement(i).GetTag()
-                    << "  " << FromDcmtkBridge::GetTagName(query.GetElement(i))
-                    << " = " << query.GetElement(i).GetValue().GetContent();
+          CLOG(INFO, DICOM) << "  " << query.GetElement(i).GetTag()
+                            << "  " << FromDcmtkBridge::GetTagName(query.GetElement(i))
+                            << " = " << query.GetElement(i).GetValue().GetContent();
         }
       }
     }
@@ -533,7 +534,7 @@
 
     if (!LookupIdentifiers(publicIds, level, input))
     {
-      LOG(ERROR) << "Cannot determine what resources are requested by C-GET";
+      CLOG(ERROR, DICOM) << "Cannot determine what resources are requested by C-GET";
       return false; 
     }
 
@@ -549,8 +550,8 @@
     for (std::list<std::string>::const_iterator
            resource = publicIds.begin(); resource != publicIds.end(); ++resource)
     {
-      LOG(INFO) << "C-GET: Sending resource " << *resource
-                << " to modality \"" << originatorAet << "\"";
+      CLOG(INFO, DICOM) << "C-GET: Sending resource " << *resource
+                        << " to modality \"" << originatorAet << "\"";
       
       std::list<std::string> tmp;
       context_.GetIndex().GetChildInstances(tmp, *resource);
--- a/OrthancServer/Sources/OrthancMoveRequestHandler.cpp	Wed Nov 04 17:40:25 2020 +0100
+++ b/OrthancServer/Sources/OrthancMoveRequestHandler.cpp	Wed Nov 04 17:48:11 2020 +0100
@@ -81,8 +81,8 @@
 
         for (size_t i = 0; i < publicIds.size(); i++)
         {
-          LOG(INFO) << "Sending resource " << publicIds[i] << " to modality \""
-                    << targetAet << "\" in synchronous mode";
+          CLOG(INFO, DICOM) << "Sending resource " << publicIds[i] << " to modality \""
+                            << targetAet << "\" in synchronous mode";
 
           std::list<std::string> tmp;
           context_.GetIndex().GetChildInstances(tmp, publicIds[i]);
@@ -162,8 +162,8 @@
 
         for (size_t i = 0; i < publicIds.size(); i++)
         {
-          LOG(INFO) << "Sending resource " << publicIds[i] << " to modality \""
-                    << targetAet << "\" in asynchronous mode";
+          CLOG(INFO, DICOM) << "Sending resource " << publicIds[i] << " to modality \""
+                            << targetAet << "\" in asynchronous mode";
 
           std::list<std::string> tmp;
           context_.GetIndex().GetChildInstances(tmp, publicIds[i]);
@@ -334,7 +334,7 @@
   {
     MetricsRegistry::Timer timer(context_.GetMetricsRegistry(), "orthanc_move_scp_duration_ms");
 
-    LOG(WARNING) << "Move-SCU request received for AET \"" << targetAet << "\"";
+    CLOG(WARNING, DICOM) << "Move-SCU request received for AET \"" << targetAet << "\"";
 
     {
       DicomArray query(input);
@@ -342,9 +342,9 @@
       {
         if (!query.GetElement(i).GetValue().IsNull())
         {
-          LOG(INFO) << "  " << query.GetElement(i).GetTag()
-                    << "  " << FromDcmtkBridge::GetTagName(query.GetElement(i))
-                    << " = " << query.GetElement(i).GetValue().GetContent();
+          CLOG(INFO, DICOM) << "  " << query.GetElement(i).GetTag()
+                            << "  " << FromDcmtkBridge::GetTagName(query.GetElement(i))
+                            << " = " << query.GetElement(i).GetValue().GetContent();
         }
       }
     }