diff options
Diffstat (limited to 'mayaPlug/shaveDebug.h')
| -rw-r--r-- | mayaPlug/shaveDebug.h | 77 |
1 files changed, 77 insertions, 0 deletions
diff --git a/mayaPlug/shaveDebug.h b/mayaPlug/shaveDebug.h new file mode 100644 index 0000000..79b72f7 --- /dev/null +++ b/mayaPlug/shaveDebug.h @@ -0,0 +1,77 @@ +#ifndef shaveDebug_h +#define shaveDebug_h + +// Shave and a Haircut +// (c) 2019 Epic Games +// US Patent 6720962 + +#ifndef _DEBUG + +#define INFO(msg) +#define ENTER() +#define LEAVE() return +#define RETURN(value) return (value) + +#else + +#ifdef __GNUG__ +# define DEBUGFUNC __PRETTY_FUNCTION__ +#else +# ifdef _WIN32 +# define DEBUGFUNC __FUNCTION__ +# else +# define DEBUGFUNC __func__ +# endif +#endif + +#define ENTER() shaveDebug::enter(DEBUGFUNC, __LINE__, __FILE__) +#define LEAVE() { shaveDebug::leave(DEBUGFUNC, __LINE__, __FILE__); return; } +#define RETURN(value) { shaveDebug::leave(DEBUGFUNC, __LINE__, __FILE__); return (value); } +#define INFO(msg) shaveDebug::logMsg(msg, __LINE__, __FILE__) + +#include <stdio.h> +#include <maya/MString.h> +#include <maya/MStringArray.h> + + +class shaveDebug +{ +public: + static void enter( + MString method, + unsigned int lineNumber, + const char* file + ); + + static void indent(); + static void init(); + + static void leave( + MString method, + unsigned int lineNumber, + const char* file + ); + + static void logMsg( + MString msg, + unsigned int lineNumber, + const char* file + ); + + static void outputHeader( + const char* tag, + MString method, + unsigned int lineNumber, + const char* file + ); + +private: + static bool mInitialized; + static FILE* mLogFile; + static MStringArray mStack; + static unsigned int mStackDepth; +}; + +#endif + +#endif |