changeset 3654:427a13084241

OrthancHelpers::ShortenId to display shortened uuid in logs
author Alain Mazy <alain@mazy.be>
date Fri, 07 Feb 2020 09:35:18 +0100
parents b6a569e6e85b
children e7248fa2738f
files Resources/Samples/CppHelpers/Logging/ILogger.h
diffstat 1 files changed, 15 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/Resources/Samples/CppHelpers/Logging/ILogger.h	Thu Jan 23 12:58:08 2020 +0100
+++ b/Resources/Samples/CppHelpers/Logging/ILogger.h	Fri Feb 07 09:35:18 2020 +0100
@@ -8,6 +8,21 @@
 namespace OrthancHelpers
 {
 
+
+  inline std::string ShortenId(const std::string& orthancUuid)
+  {
+    size_t firstHyphenPos = orthancUuid.find_first_of('-');
+    if (firstHyphenPos == std::string::npos)
+    {
+      return orthancUuid;
+    }
+    else
+    {
+      return orthancUuid.substr(0, firstHyphenPos);
+    }
+  }
+
+
   // Interface for loggers providing the same interface
   // in Orthanc framework or in an Orthanc plugins.
   // Furthermore, compared to the LOG and VLOG macros,