DCL 4.0
Loading...
Searching...
No Matches
_trace.h
Go to the documentation of this file.
1#ifndef __DEBUG_H__
2#define __DEBUG_H__
3
4#include <stdio.h>
5#include <stdarg.h>
6
7#if __DCL_WINDOWS
8#define __DEBUG_TRACE__ "D:/temp/dcl_hsc_ap2.txt"
9#else
10#define __DEBUG_TRACE__ "/dev/pts/0"
11#endif
12
13#ifndef __THIS_FILE__
14#define __THIS_FILE__ __FILE__
15#endif
16
17static void trace(const char* fmt, ...)
18{
19 va_list args;
20 FILE* fp = fopen(__DEBUG_TRACE__, "a");
21 if (fp)
22 {
23#if __DCL_DEBUG
24 fprintf(fp, "D ");
25#else
26 fprintf(fp, "R ");
27#endif
28 va_start(args, fmt);
29 vfprintf(fp, fmt, args);
30 va_end(args);
31 fclose(fp);
32 }
33}
34
35#define _TRACE0(str) \
36 trace("%s(%d) %s: %s", __THIS_FILE__, __LINE__, __PRETTY_FUNCTION__, str)
37#define _TRACE1(fmt, arg1) \
38 trace("%s(%d) %s: " fmt, __THIS_FILE__, __LINE__, __PRETTY_FUNCTION__, arg1)
39#define _TRACE2(fmt, arg1, arg2) \
40 trace("%s(%d) %s: " fmt, __THIS_FILE__, __LINE__, __PRETTY_FUNCTION__, arg1, arg2)
41#define _TRACE3(fmt, arg1, arg2, arg3) \
42 trace("%s(%d) %s: " fmt, __THIS_FILE__, __LINE__, __PRETTY_FUNCTION__, arg1, arg2, arg3)
43
44#endif
#define __DEBUG_TRACE__
Definition _trace.h:10