diff OrthancFramework/Sources/Logging.cpp @ 4275:d7a50b7b8466

Dynamically access and/or change the verbosity of logging categories with the REST API
author Sebastien Jodogne <s.jodogne@gmail.com>
date Tue, 03 Nov 2020 14:41:27 +0100
parents 0034f855c023
children 6dcadbf1a8af
line wrap: on
line diff
--- a/OrthancFramework/Sources/Logging.cpp	Tue Nov 03 12:28:25 2020 +0100
+++ b/OrthancFramework/Sources/Logging.cpp	Tue Nov 03 14:41:27 2020 +0100
@@ -228,29 +228,42 @@
     }
 
 
-    size_t GetCategoriesCount()
+    unsigned int GetCategoriesCount()
     {
       return 5;
     }
 
 
-    const char* GetCategoryName(size_t i)
+    const char* GetCategoryName(unsigned int i)
     {
-      switch (i)
+      if (i < GetCategoriesCount())
+      {
+        return GetCategoryName(static_cast<LogCategory>(1 << i));
+      }
+      else
       {
-        case 0:
+        throw OrthancException(ErrorCode_ParameterOutOfRange);
+      }
+    }
+    
+
+    const char* GetCategoryName(LogCategory category)
+    {
+      switch (category)
+      {
+        case LogCategory_GENERIC:
           return "generic";
-          
-        case 1:
+            
+        case LogCategory_PLUGINS:
           return "plugins";
-          
-        case 2:
+            
+        case LogCategory_REST:
           return "rest";
-          
-        case 3:
+            
+        case LogCategory_DICOM:
           return "dicom";
-          
-        case 4:
+            
+        case LogCategory_SQLITE:
           return "sqlite";
 
         default: