Index: /trunk/freebob/src/debugmodule.h =================================================================== --- /trunk/freebob/src/debugmodule.h (revision 43) +++ /trunk/freebob/src/debugmodule.h (revision 51) @@ -33,9 +33,22 @@ #define DEBUG_LEVEL_TRANSFERS (1<<5) +#define DEBUG_LEVEL_SCHEDULER (1<<6) + // convenience defines -#define DEBUG_LEVEL_ALL (DEBUG_LEVEL_INFO | DEBUG_LEVEL_DEVICE | DEBUG_LEVEL_SUBUNIT | DEBUG_LEVEL_DESCRIPTOR | DEBUG_LEVEL_INFOBLOCK | DEBUG_LEVEL_TRANSFERS ) -#define DEBUG_LEVEL_LOW (DEBUG_LEVEL_INFO | DEBUG_LEVEL_DEVICE) -#define DEBUG_LEVEL_MODERATE (DEBUG_LEVEL_INFO | DEBUG_LEVEL_DEVICE | DEBUG_LEVEL_SUBUNIT) -#define DEBUG_LEVEL_HIGH (DEBUG_LEVEL_MODERATE | DEBUG_LEVEL_DESCRIPTOR | DEBUG_LEVEL_INFOBLOCK) +#define DEBUG_LEVEL_ALL ( DEBUG_LEVEL_INFO \ + | DEBUG_LEVEL_DEVICE \ + | DEBUG_LEVEL_SUBUNIT \ + | DEBUG_LEVEL_DESCRIPTOR \ + | DEBUG_LEVEL_INFOBLOCK \ + | DEBUG_LEVEL_TRANSFERS \ + | DEBUG_LEVEL_SCHEDULER ) +#define DEBUG_LEVEL_LOW ( DEBUG_LEVEL_INFO \ + | DEBUG_LEVEL_DEVICE ) +#define DEBUG_LEVEL_MODERATE ( DEBUG_LEVEL_INFO \ + | DEBUG_LEVEL_DEVICE \ + | DEBUG_LEVEL_SUBUNIT ) +#define DEBUG_LEVEL_HIGH ( DEBUG_LEVEL_MODERATE \ + | DEBUG_LEVEL_DESCRIPTOR \ + | DEBUG_LEVEL_INFOBLOCK ) unsigned char toAscii( unsigned char c ); @@ -48,18 +61,18 @@ virtual ~DebugBase(); - void setDebugLevel( int level ) + void setLevel( int level ) { m_level = level; } - virtual void debugError( const char* file, - const char* function, - unsigned int line, + virtual void error( const char* file, + const char* function, + unsigned int line, + const char* format, ... ) const = 0; + virtual void print( int level, + const char* file, + const char* function, + unsigned int line, + const char* format, ... ) const = 0; + virtual void printShort( int level, const char* format, ... ) const = 0; - virtual void debugPrint( int level, - const char* file, - const char* function, - unsigned int line, - const char* format, ... ) const = 0; - virtual void debugPrintShort( int level, - const char* format, ... ) const = 0; protected: @@ -72,15 +85,15 @@ virtual ~DebugStandard(); - virtual void debugError( const char* file, - const char* function, - unsigned int line, + virtual void error( const char* file, + const char* function, + unsigned int line, + const char* format, ... ) const; + virtual void print( int level, + const char* file, + const char* function, + unsigned int line, + const char* format, ... ) const; + virtual void printShort( int level, const char* format, ... ) const; - virtual void debugPrint( int level, - const char* file, - const char* function, - unsigned int line, - const char* format, ... ) const; - virtual void debugPrintShort( int level, - const char* format, ... ) const; }; @@ -90,16 +103,16 @@ virtual ~DebugAnsiColor(); - virtual void debugError( const char* file, - const char* function, - unsigned int line, + virtual void error( const char* file, + const char* function, + unsigned int line, + const char* format, ... ) const; + virtual void print( int level, + const char* file, + const char* function, + unsigned int line, + const char* format, ... ) const; + virtual void printShort( int level, const char* format, ... ) const; - virtual void debugPrint( int level, - const char* file, - const char* function, - unsigned int line, - const char* format, ... ) const; - virtual void debugPrintShort( int level, - const char* format, ... ) const; - + protected: const char* getLevelColor( int level ) const; @@ -111,15 +124,15 @@ virtual ~DebugHtml(); - void debugError( const char* file, - const char* function, - unsigned int line, + void error( const char* file, + const char* function, + unsigned int line, + const char* format, ... ) const; + void print( int level, + const char* file, + const char* function, + unsigned int line, + const char* format, ... ) const; + void printShort( int level, const char* format, ... ) const; - void debugPrint( int level, - const char* file, - const char* function, - unsigned int line, - const char* format, ... ) const; - void debugPrintShort( int level, - const char* format, ... ) const; protected: @@ -129,12 +142,21 @@ #ifdef DEBUG -#define setDebugLevel(x) m_debug.setDebugLevel( x ) -#define debugError(format, args...) m_debug.debugError( __FILE__, __FUNCTION__, __LINE__, format, ##args ) -#define debugPrint(level, format, args...) m_debug.debugPrint( level, __FILE__, __FUNCTION__, __LINE__, format, ##args ) -#define debugPrintShort(level, format, args...) m_debug.debugPrintShort( level, format, ##args ) +#define setDebugLevel(x) m_debug.setLevel( x ) +#define debugError(format, args...) m_debug.error( __FILE__, __FUNCTION__, __LINE__, format, ##args ) +#define debugPrint(level, format, args...) m_debug.print( level, __FILE__, __FUNCTION__, __LINE__, format, ##args ) +#define debugPrintShort(level, format, args...) m_debug.printShort( level, format, ##args ) + +#define setGlobalDebugLevel(x) gGlobalDebugModule.setLevel( x ) +#define debugGlobalError(format, args...) gGlobalDebugModule.error( __FILE__, __FUNCTION__, __LINE__, format, ##args ) +#define debugGlobalPrint(level, format, args...) gGlobalDebugModule.print( level, __FILE__, __FUNCTION__, __LINE__, format, ##args ) +#define debugGlobalPrintShort(level, format, args...) gGlobalDebugModule.printShort( level, format, ##args ) // XXX To change the debug module the header has to be edited // which sucks big time #define DECLARE_DEBUG_MODULE DebugAnsiColor m_debug + +// For static functions +#define DECLARE_GLOBAL_DEBUG_MODULE DebugAnsiColor gGlobalDebugModule +#define USE_GLOBAL_DEBUG_MODULE extern DebugAnsiColor gGlobalDebugModule #else /* !DEBUG */ Index: /trunk/freebob/src/debugmodule.cpp =================================================================== --- /trunk/freebob/src/debugmodule.cpp (revision 43) +++ /trunk/freebob/src/debugmodule.cpp (revision 51) @@ -43,5 +43,5 @@ void -DebugStandard::debugError( const char* file, +DebugStandard::error( const char* file, const char* function, unsigned int line, @@ -57,5 +57,5 @@ void -DebugStandard::debugPrint( int level, +DebugStandard::print( int level, const char* file, const char* function, @@ -74,5 +74,5 @@ void -DebugStandard::debugPrintShort( int level, +DebugStandard::printShort( int level, const char* format, ... ) const { @@ -95,8 +95,8 @@ void -DebugAnsiColor::debugError( const char* file, - const char* function, - unsigned int line, - const char* format, ... ) const +DebugAnsiColor::error( const char* file, + const char* function, + unsigned int line, + const char* format, ... ) const { va_list arg; @@ -111,9 +111,9 @@ void -DebugAnsiColor::debugPrint( int level, - const char* file, - const char* function, - unsigned int line, - const char* format, ... ) const +DebugAnsiColor::print( int level, + const char* file, + const char* function, + unsigned int line, + const char* format, ... ) const { if (level & m_level) { @@ -130,6 +130,6 @@ void -DebugAnsiColor::debugPrintShort( int level, - const char* format, ... ) const +DebugAnsiColor::printShort( int level, + const char* format, ... ) const { if (level & m_level) { @@ -183,8 +183,8 @@ void -DebugHtml::debugError( const char* file, - const char* function, - unsigned int line, - const char* format, ... ) const +DebugHtml::error( const char* file, + const char* function, + unsigned int line, + const char* format, ... ) const { va_list arg; @@ -199,9 +199,9 @@ void -DebugHtml::debugPrint( int level, - const char* file, - const char* function, - unsigned int line, - const char* format, ... ) const +DebugHtml::print( int level, + const char* file, + const char* function, + unsigned int line, + const char* format, ... ) const { if (level & m_level) { @@ -218,5 +218,5 @@ void -DebugHtml::debugPrintShort( int level, const char* format, ... ) const +DebugHtml::printShort( int level, const char* format, ... ) const { if (level & m_level) {