File: debug.h

package info (click to toggle)
xstow 1.0.2-1
  • links: PTS
  • area: main
  • in suites: bullseye, buster, sid, stretch
  • size: 1,064 kB
  • ctags: 1,073
  • sloc: cpp: 7,264; sh: 1,216; makefile: 196; awk: 26
file content (58 lines) | stat: -rw-r--r-- 1,067 bytes parent folder | download | duplicates (3)
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
/*
 * $Log: debug.h,v $
 * Revision 1.3  2010/07/21 19:38:25  martin
 * gcc-4 Port
 *
 * Revision 1.2  2005/07/04 21:59:42  martin
 * added logging to all files
 *
 */
#ifndef debug_h
#define debug_h

#include "format.h"
#include "range.h"
#include "backtrace.h"

struct EnumModule {
  enum ETYPE {
	FIRST__ = - 2,
	ALL  = -1,
	ARG  = 1,
	MAIN,
	TREE,
	CPPDIR,
	SETUP,
	NIGNORE,
	MERGE_INFO,
	LAST__
  };
};

typedef EnumRange<EnumModule> MODULE;
typedef MODULE DModule;

extern Format::PrintF<std::ostream> out;
extern Format::PrintF<std::ostream> vout;
extern Format::PrintF<std::ostream> eout;

/*
DModule string2module( std::string module );
*/
MODULE::ETYPE string2module( std::string module );

std::string x2s( MODULE module );

extern std::string progname;

#define ERROR eout( MODULE::ALL )[0]( "%s: ", progname )[0]

#ifdef NDEBUG
#  define DEBUG( expr )
#  define DEBUG_OUT( level, module ) out(module)[level]
#else
#  define DEBUG( expr ) expr
#  define DEBUG_OUT( level, module ) out(module)[level]( "%s:%s: ", __FILE__, __LINE__ )[level]
#endif

#endif