[beast: 10/57] SFI: print startup time when using debug output



commit cfbef509b2028ceb8f7115698ded50b77ba1b57f
Author: Tim Janik <timj gnu org>
Date:   Fri Jul 14 01:39:20 2017 +0200

    SFI: print startup time when using debug output
    
    Signed-off-by: Tim Janik <timj gnu org>

 sfi/bcore.cc |   18 ++++++++++++++++++
 1 files changed, 18 insertions(+), 0 deletions(-)
---
diff --git a/sfi/bcore.cc b/sfi/bcore.cc
index 452b016..5dfb402 100644
--- a/sfi/bcore.cc
+++ b/sfi/bcore.cc
@@ -84,6 +84,24 @@ debug_diagnostic (const char *prefix, const std::string &message)
   printerr ("%u.%06u %s: %s%s", tv.tv_sec, tv.tv_usec, pprefix, message, newline);
 }
 
+struct DebugStartup {
+  DebugStartup()
+  {
+    if (debug_key_enabled ("") ||       // force debug_any_enabled initialization
+        debug_any_enabled)              // run DebugStartup if *any* debugging is enabled
+      {
+        const time_t now = time (NULL);
+        struct tm gtm = { 0, };
+        gmtime_r (&now, &gtm);
+        char buffer[1024] = { 0, };
+        strftime (buffer, sizeof (buffer) - 1, "%Y-%m-%d %H:%M:%S UTC", &gtm);
+        debug_diagnostic (NULL, "startup: " + String() + buffer);
+      }
+  }
+};
+
+static DebugStartup _debug_startup __attribute__ ((init_priority (101)));
+
 } // Internal
 
 } // Bse


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]