1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
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
|