BDS Public
Beam-lib  2.16.3
This is the Beam C++ class library.
BDebug.h
Go to the documentation of this file.
1 /*******************************************************************************
2  * BDebug.h Debug information and routines
3  * T.Barnaby, BEAM Ltd, 2009-01-05
4  * Copyright (c) 2012 All Right Reserved, Beam Ltd, http://www.beam.ltd.uk
5  *******************************************************************************
6  */
7 #ifndef BDebug_H
8 #define BDebug_H
9 
10 #include <stdio.h>
11 #include <time.h>
12 
13 #define BDebug_STD 0x000001
14 
15 extern int bdebug;
16 
17 void bhd8(const void* data, unsigned int n);
18 void bhd8a(const void* data, unsigned int n);
19 void bhda8(const void* data, unsigned int n);
20 void bhd32(const void* data, unsigned int n);
21 void bhds32(const void* data, unsigned int n);
22 double getTime();
23 void setDebug(int debug);
24 void tprintf(int log, const char* fmt, ...);
25 
26 pid_t bgettid();
27 
29 #if BDEBUG
30 #define dprintf(level, fmt, a...) if((level) & bdebug) tprintf(1, fmt, ##a);
31 #else
32 #define dprintf(level, fmt, a...)
33 #endif
34 
36 #if !TARGET_win32 && !TARGET_win64
37 #include <syslog.h>
38 
39 #if BDEBUG
40 #define nprintf(fmt, a...) { syslog(LOG_NOTICE, fmt, ##a); tprintf(0, fmt, ##a); }
41 #define wprintf(fmt, a...) { syslog(LOG_WARNING, fmt, ##a); tprintf(0, fmt, ##a); }
42 #define eprintf(fmt, a...) { syslog(LOG_ERR, fmt, ##a); tprintf(0, fmt, ##a); }
43 #else
44 #define nprintf(fmt, a...) syslog(LOG_NOTICE, fmt, ##a)
45 #define wprintf(fmt, a...) syslog(LOG_WARNING, fmt, ##a)
46 #define eprintf(fmt, a...) syslog(LOG_ERR, fmt, ##a)
47 #endif
48 #endif
49 
50 #if BDEBUGL1
51 #define dl1printf(fmt, a...) printf(fmt, ##a);
52 #else
53 #define dl1printf(fmt, a...)
54 #endif
55 
56 #if BDEBUGL2
57 #define dl2printf(fmt, a...) printf(fmt, ##a);
58 #else
59 #define dl2printf(fmt, a...)
60 #endif
61 
62 #if BDEBUGL3
63 #define dl3printf(fmt, a...) printf(fmt, ##a);
64 #else
65 #define dl3printf(fmt, a...)
66 #endif
67 
68 #if BDEBUGL4
69 #define dl4printf(fmt, a...) printf(fmt, ##a);
70 #else
71 #define dl4printf(fmt, a...)
72 #endif
73 
75 public:
78 
79  void dumpBacktraceStdout(char* comment);
80  int dumpBacktraceFile(char* fileName, char* comment);
81  void dumpBacktraceSyslog(char* comment);
82  void dumpBacktrace(char* strBuf, int strBufLen, char* comment);
83 private:
84 };
85 
86 #endif
int bdebug
Definition: BDebug.cpp:17
void tprintf(int log, const char *fmt,...)
pid_t bgettid()
void dumpBacktraceSyslog(char *comment)
void bhd8a(const void *data, unsigned int n)
Definition: BDebug.cpp:31
void bhds32(const void *data, unsigned int n)
void bhda8(const void *data, unsigned int n)
Definition: BDebug.cpp:54
void bhd32(const void *data, unsigned int n)
Definition: BDebug.cpp:68
int dumpBacktraceFile(char *fileName, char *comment)
void dumpBacktrace(char *strBuf, int strBufLen, char *comment)
char data[8]
Definition: BoapMc1.h:21
double getTime()
Definition: BDebug.cpp:95
void setDebug(int debug)
Definition: BDebug.cpp:103
void bhd8(const void *data, unsigned int n)
Definition: BDebug.cpp:19
Definition: BDebug.h:74
void dumpBacktraceStdout(char *comment)