diff Samples/CommonHelpers.h @ 1382:9d138883be66

Proper command-line parameter management for SDL sample
author Benjamin Golinvaux <bgo@osimis.io>
date Wed, 22 Apr 2020 19:55:34 +0200
parents
children
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Samples/CommonHelpers.h	Wed Apr 22 19:55:34 2020 +0200
@@ -0,0 +1,35 @@
+#pragma once
+
+#include <string>
+#include <iostream>
+
+#include <Core/Logging.h>
+
+namespace OrthancStoneHelpers
+{
+  inline void SetLogLevel(std::string logLevel)
+  {
+    boost::to_lower(logLevel);
+    if (logLevel == "warning")
+    {
+      Orthanc::Logging::EnableInfoLevel(false);
+      Orthanc::Logging::EnableTraceLevel(false);
+    }
+    else if (logLevel == "info")
+    {
+      Orthanc::Logging::EnableInfoLevel(true);
+      Orthanc::Logging::EnableTraceLevel(false);
+    }
+    else if (logLevel == "trace")
+    {
+      Orthanc::Logging::EnableInfoLevel(true);
+      Orthanc::Logging::EnableTraceLevel(true);
+    }
+    else
+    {
+      std::cerr << "Unknown log level \"" << logLevel << "\". Will use TRACE as default!";
+      Orthanc::Logging::EnableInfoLevel(true);
+      Orthanc::Logging::EnableTraceLevel(true);
+    }
+  }
+}
\ No newline at end of file