Add ability to set libpbd debug options via PBD_DEBUG environment var
authorTim Mayberry <mojofunk@gmail.com>
Tue, 2 Dec 2014 13:36:14 +0000 (20:36 +0700)
committerTim Mayberry <mojofunk@gmail.com>
Wed, 3 Dec 2014 10:31:05 +0000 (17:31 +0700)
libs/pbd/pbd.cc

index 738a676d4c90e3b43e48529fc71ce5bff66e57ce..145e1b91a8080104d801e1a06974a6e2ee454919 100644 (file)
@@ -19,6 +19,7 @@
 
 #include <iostream>
 #include <cstdlib>
+#include <string>
 
 #ifdef PLATFORM_WINDOWS
 #include <fcntl.h>
@@ -43,6 +44,19 @@ static bool libpbd_initialized = false;
 
 }
 
+void
+set_debug_options_from_env ()
+{
+       bool set;
+       std::string options;
+
+       options = Glib::getenv ("PBD_DEBUG", set);
+       if (set) {
+               std::cerr << "PBD_DEBUG=" << options << std::endl;
+               PBD::parse_debug_options (options.c_str());
+       }
+}
+
 bool
 PBD::init ()
 {
@@ -66,6 +80,8 @@ PBD::init ()
 
        setup_libpbd_enums ();
 
+       set_debug_options_from_env ();
+
        libpbd_initialized = true;
        return true;
 }