enough with umpteen "i18n.h" files. Consolidate on pbd/i18n.h
[ardour.git] / libs / pbd / debug.cc
index b42e7f047e60f64ebdd5632dc7734649a5ac75f1..419c5bfb379e32ec71fe3bc8511a80834d6db28a 100644 (file)
@@ -28,7 +28,7 @@
 
 #include "pbd/debug.h"
 
-#include "i18n.h"
+#include "pbd/i18n.h"
 
 using namespace std;
 using PBD::DebugBits;
@@ -53,6 +53,10 @@ DebugBits PBD::DEBUG::EventLoop = PBD::new_debug_bit ("eventloop");
 DebugBits PBD::DEBUG::AbstractUI = PBD::new_debug_bit ("abstractui");
 DebugBits PBD::DEBUG::FileUtils = PBD::new_debug_bit ("fileutils");
 DebugBits PBD::DEBUG::Configuration = PBD::new_debug_bit ("configuration");
+DebugBits PBD::DEBUG::UndoHistory = PBD::new_debug_bit ("undohistory");
+DebugBits PBD::DEBUG::Timing = PBD::new_debug_bit ("timing");
+DebugBits PBD::DEBUG::Threads = PBD::new_debug_bit ("threads");
+DebugBits PBD::DEBUG::Locale = PBD::new_debug_bit ("locale");
 
 /* These are debug bits that are used by backends. Since these are loaded dynamically,
    after command-line parsing, defining them in code that is part of the backend
@@ -63,12 +67,6 @@ DebugBits PBD::DEBUG::Configuration = PBD::new_debug_bit ("configuration");
    from dynamically loaded code, for use in command line parsing, is way above the pay grade
    of this debug tracing scheme.
 */
-DebugBits PBD::DEBUG::BackendMIDI = PBD::new_debug_bit ("BackendMIDI");
-DebugBits PBD::DEBUG::BackendAudio = PBD::new_debug_bit ("BackendAudio");
-DebugBits PBD::DEBUG::BackendTiming = PBD::new_debug_bit ("BackendTiming");
-DebugBits PBD::DEBUG::BackendThreads = PBD::new_debug_bit ("BackendThreads");
-
-
 DebugBits PBD::DEBUG::WavesMIDI = PBD::new_debug_bit ("WavesMIDI");
 DebugBits PBD::DEBUG::WavesAudio = PBD::new_debug_bit ("WavesAudio");
 
@@ -77,16 +75,28 @@ DebugBits PBD::debug_bits;
 DebugBits
 PBD::new_debug_bit (const char* name)
 {
-        DebugBits ret;
-        ret.set (_debug_bit++, 1);
-        _debug_bit_map().insert (make_pair (name, ret));
+       DebugBits ret;
+       DebugMap::iterator i =_debug_bit_map().find (name);
+
+       if (i != _debug_bit_map().end()) {
+               return i->second;
+       }
+
+       if (_debug_bit >= debug_bits.size()) {
+               cerr << "Too many debug bits defined, offender was " << name << endl;
+               abort ();
+               /*NOTREACHED*/
+       }
+
+       ret.set (_debug_bit++, 1);
+       _debug_bit_map().insert (make_pair (name, ret));
         return ret;
 }
 
 void
 PBD::debug_print (const char* prefix, string str)
 {
-       cerr << prefix << ": " << str;
+       cout << prefix << ": " << str;
 }
 
 int
@@ -114,13 +124,13 @@ PBD::parse_debug_options (const char* str)
 
                         if (strncasecmp (cstr, i->first, strlen (cstr)) == 0) {
                                bits |= i->second;
-                               cerr << i->first << " set ... debug bits now set to " << bits << " using " << i->second << endl;
+                               cout << i->first << " set ... debug bits now set to " << bits << " using " << i->second << endl;
                         }
                 }
        }
-       
+
        debug_bits = bits;
-       
+
        return 0;
 }
 
@@ -128,7 +138,7 @@ void
 PBD::list_debug_options ()
 {
        cout << _("The following debug options are available. Separate multiple options with commas.\nNames are case-insensitive and can be abbreviated.") << endl << endl;
-       cout << '\t' << X_("all") << endl; 
+       cout << '\t' << X_("all") << endl;
 
        vector<string> options;