changeset 4294:0923247e69f6

log categories: rest -> http + added lua & jobs
author Alain Mazy <alain@mazy.be>
date Thu, 05 Nov 2020 11:43:32 +0100
parents 29729b7eb6ab
children 90f91b78d708
files OrthancFramework/Sources/HttpServer/HttpServer.cpp OrthancFramework/Sources/Logging.cpp OrthancFramework/Sources/Logging.h OrthancFramework/UnitTestsSources/LoggingTests.cpp OrthancServer/Sources/OrthancRestApi/OrthancRestApi.cpp OrthancServer/Sources/OrthancRestApi/OrthancRestModalities.cpp OrthancServer/Sources/OrthancRestApi/OrthancRestResources.cpp
diffstat 7 files changed, 41 insertions(+), 17 deletions(-) [+]
line wrap: on
line diff
--- a/OrthancFramework/Sources/HttpServer/HttpServer.cpp	Thu Nov 05 11:23:47 2020 +0100
+++ b/OrthancFramework/Sources/HttpServer/HttpServer.cpp	Thu Nov 05 11:43:32 2020 +0100
@@ -1088,7 +1088,7 @@
 
       std::transform(name.begin(), name.end(), name.begin(), ::tolower);
       headers.insert(std::make_pair(name, value));
-      CLOG(TRACE, REST) << "HTTP header: [" << name << "]: [" << value << "]";
+      CLOG(TRACE, HTTP) << "HTTP header: [" << name << "]: [" << value << "]";
     }
 
     if (server.IsHttpCompressionEnabled())
--- a/OrthancFramework/Sources/Logging.cpp	Thu Nov 05 11:23:47 2020 +0100
+++ b/OrthancFramework/Sources/Logging.cpp	Thu Nov 05 11:43:32 2020 +0100
@@ -206,9 +206,9 @@
         target = LogCategory_PLUGINS;
         return true;
       }
-      else if (category == "rest")
+      else if (category == "http")
       {
-        target = LogCategory_REST;
+        target = LogCategory_HTTP;
         return true;
       }
       else if (category == "dicom")
@@ -221,6 +221,16 @@
         target = LogCategory_SQLITE;
         return true;
       }
+      else if (category == "jobs")
+      {
+        target = LogCategory_JOBS;
+        return true;
+      }
+      else if (category == "lua")
+      {
+        target = LogCategory_LUA;
+        return true;
+      }
       else
       {
         return false;
@@ -230,7 +240,7 @@
 
     unsigned int GetCategoriesCount()
     {
-      return 5;
+      return 7;
     }
 
 
@@ -257,8 +267,8 @@
         case LogCategory_PLUGINS:
           return "plugins";
             
-        case LogCategory_REST:
-          return "rest";
+        case LogCategory_HTTP:
+          return "http";
             
         case LogCategory_DICOM:
           return "dicom";
@@ -266,6 +276,12 @@
         case LogCategory_SQLITE:
           return "sqlite";
 
+        case LogCategory_JOBS:
+          return "jobs";
+
+        case LogCategory_LUA:
+          return "lua";
+
         default:
           throw OrthancException(ErrorCode_ParameterOutOfRange);
       }
--- a/OrthancFramework/Sources/Logging.h	Thu Nov 05 11:23:47 2020 +0100
+++ b/OrthancFramework/Sources/Logging.h	Thu Nov 05 11:43:32 2020 +0100
@@ -62,9 +62,11 @@
     {
       LogCategory_GENERIC = (1 << 0),
       LogCategory_PLUGINS = (1 << 1),
-      LogCategory_REST    = (1 << 2),
+      LogCategory_HTTP    = (1 << 2),
       LogCategory_SQLITE  = (1 << 3),
-      LogCategory_DICOM   = (1 << 4)
+      LogCategory_DICOM   = (1 << 4),
+      LogCategory_JOBS    = (1 << 5),
+      LogCategory_LUA     = (1 << 6),
     };
     
     ORTHANC_PUBLIC const char* EnumerationToString(LogLevel level);
--- a/OrthancFramework/UnitTestsSources/LoggingTests.cpp	Thu Nov 05 11:23:47 2020 +0100
+++ b/OrthancFramework/UnitTestsSources/LoggingTests.cpp	Thu Nov 05 11:43:32 2020 +0100
@@ -368,12 +368,14 @@
   Logging::LogCategory c;
   ASSERT_TRUE(Logging::LookupCategory(c, "generic"));  ASSERT_EQ(Logging::LogCategory_GENERIC, c);
   ASSERT_TRUE(Logging::LookupCategory(c, "plugins"));  ASSERT_EQ(Logging::LogCategory_PLUGINS, c);
-  ASSERT_TRUE(Logging::LookupCategory(c, "rest"));     ASSERT_EQ(Logging::LogCategory_REST, c);
+  ASSERT_TRUE(Logging::LookupCategory(c, "http"));     ASSERT_EQ(Logging::LogCategory_HTTP, c);
   ASSERT_TRUE(Logging::LookupCategory(c, "sqlite"));   ASSERT_EQ(Logging::LogCategory_SQLITE, c);
   ASSERT_TRUE(Logging::LookupCategory(c, "dicom"));    ASSERT_EQ(Logging::LogCategory_DICOM, c);
+  ASSERT_TRUE(Logging::LookupCategory(c, "jobs"));     ASSERT_EQ(Logging::LogCategory_JOBS, c);
+  ASSERT_TRUE(Logging::LookupCategory(c, "lua"));     ASSERT_EQ(Logging::LogCategory_LUA, c);
   ASSERT_FALSE(Logging::LookupCategory(c, "nope"));
 
-  ASSERT_EQ(5u, Logging::GetCategoriesCount());
+  ASSERT_EQ(7u, Logging::GetCategoriesCount());
 
   std::set<std::string> s;
   for (size_t i = 0; i < Logging::GetCategoriesCount(); i++)
@@ -383,18 +385,22 @@
     s.insert(Logging::GetCategoryName(i));
   }
 
-  ASSERT_EQ(5u, s.size());
+  ASSERT_EQ(7u, s.size());
   ASSERT_TRUE(s.find("generic") != s.end());
   ASSERT_TRUE(s.find("plugins") != s.end());
-  ASSERT_TRUE(s.find("rest") != s.end());
+  ASSERT_TRUE(s.find("http") != s.end());
   ASSERT_TRUE(s.find("sqlite") != s.end());
   ASSERT_TRUE(s.find("dicom") != s.end());
+  ASSERT_TRUE(s.find("lua") != s.end());
+  ASSERT_TRUE(s.find("jobs") != s.end());
 
   ASSERT_THROW(Logging::GetCategoryName(Logging::GetCategoriesCount()), OrthancException);
 
   ASSERT_STREQ("generic", Logging::GetCategoryName(Logging::LogCategory_GENERIC));
   ASSERT_STREQ("plugins", Logging::GetCategoryName(Logging::LogCategory_PLUGINS));
-  ASSERT_STREQ("rest", Logging::GetCategoryName(Logging::LogCategory_REST));
+  ASSERT_STREQ("http", Logging::GetCategoryName(Logging::LogCategory_HTTP));
   ASSERT_STREQ("sqlite", Logging::GetCategoryName(Logging::LogCategory_SQLITE));
   ASSERT_STREQ("dicom", Logging::GetCategoryName(Logging::LogCategory_DICOM));
+  ASSERT_STREQ("lua", Logging::GetCategoryName(Logging::LogCategory_LUA));
+  ASSERT_STREQ("jobs", Logging::GetCategoryName(Logging::LogCategory_JOBS));
 }
--- a/OrthancServer/Sources/OrthancRestApi/OrthancRestApi.cpp	Thu Nov 05 11:23:47 2020 +0100
+++ b/OrthancServer/Sources/OrthancRestApi/OrthancRestApi.cpp	Thu Nov 05 11:43:32 2020 +0100
@@ -113,7 +113,7 @@
   {
     ServerContext& context = OrthancRestApi::GetContext(call);
 
-    CLOG(INFO, REST) << "Receiving a DICOM file of " << call.GetBodySize() << " bytes through HTTP";
+    CLOG(INFO, HTTP) << "Receiving a DICOM file of " << call.GetBodySize() << " bytes through HTTP";
 
     if (call.GetBodySize() == 0)
     {
--- a/OrthancServer/Sources/OrthancRestApi/OrthancRestModalities.cpp	Thu Nov 05 11:23:47 2020 +0100
+++ b/OrthancServer/Sources/OrthancRestApi/OrthancRestModalities.cpp	Thu Nov 05 11:43:32 2020 +0100
@@ -1587,7 +1587,7 @@
 
           for (size_t j = 0; j < orthancId.size(); j++)
           {
-            CLOG(INFO, REST) << "Storage commitment - Removing SOP instance UID / Orthanc ID: "
+            CLOG(INFO, HTTP) << "Storage commitment - Removing SOP instance UID / Orthanc ID: "
                              << sopInstanceUids[i] << " / " << orthancId[j];
 
             Json::Value tmp;
--- a/OrthancServer/Sources/OrthancRestApi/OrthancRestResources.cpp	Thu Nov 05 11:23:47 2020 +0100
+++ b/OrthancServer/Sources/OrthancRestApi/OrthancRestResources.cpp	Thu Nov 05 11:43:32 2020 +0100
@@ -1351,12 +1351,12 @@
 
     if (ok)
     {
-      CLOG(INFO, REST) << "The attachment " << name << " of resource " << publicId << " has the right MD5";
+      CLOG(INFO, HTTP) << "The attachment " << name << " of resource " << publicId << " has the right MD5";
       call.GetOutput().AnswerBuffer("{}", MimeType_Json);
     }
     else
     {
-      CLOG(INFO, REST) << "The attachment " << name << " of resource " << publicId << " has bad MD5!";
+      CLOG(INFO, HTTP) << "The attachment " << name << " of resource " << publicId << " has bad MD5!";
     }
   }