/[pcsclite]/trunk/Drivers/ccid/src/debug.h
ViewVC logotype

Contents of /trunk/Drivers/ccid/src/debug.h

Parent Directory Parent Directory | Revision Log Revision Log


Revision 580 - (show annotations) (download)
Mon Jan 5 21:22:03 2004 UTC (9 years, 4 months ago) by rousseau
File MIME type: text/plain
File size: 3740 byte(s)
also print the function name (__FUNCTION__) in the debug messages
1 /*
2 debug.h: log (or not) messages using syslog
3 Copyright (C) 2003 Ludovic Rousseau
4
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version.
9
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 */
19
20 /*
21 * $Id$
22 */
23
24 /*
25 * DEBUG_CRITICAL("text");
26 * print "text" is DEBUG_LEVEL_CRITICAL and DEBUG_STDERR is defined
27 * send "text" to syslog if DEBUG_LEVEL_CRITICAL is defined
28 *
29 * DEBUG_CRITICAL2("text: %d", 1234)
30 * print "text: 1234" is DEBUG_LEVEL_CRITICAL and DEBUG_STDERR is defined
31 * send "text: 1234" to syslog if DEBUG_LEVEL_CRITICAL is defined
32 * the format string can be anything printf() can understand
33 *
34 * same thing for DEBUG_INFO and DEBUG_COMM
35 *
36 * DEBUG_XXD(msg, buffer, size) is only defined if DEBUG_LEVEL_COMM if defined
37 *
38 */
39
40 #ifndef PACKAGE /* PACKAGE is defined in ../config.h by ./configure */
41 #error "file config.h NOT included"
42 #endif
43
44 #ifndef _GCDEBUG_H_
45 #define _GCDEBUG_H_
46
47 /* You can't do #ifndef __FUNCTION__ */
48 #if !defined(__GNUC__) && !defined(__IBMC__)
49 #define __FUNCTION__ ""
50 #endif
51
52 #ifdef DEBUG_LEVEL_CRITICAL
53 #define DEBUG_CRITICAL(fmt) debug_msg("%s:%d:%s " fmt, __FILE__, __LINE__, __FUNCTION__)
54 #define DEBUG_CRITICAL2(fmt, data) debug_msg("%s:%d:%s " fmt, __FILE__, __LINE__, __FUNCTION__, data)
55 #define DEBUG_CRITICAL3(fmt, data1, data2) debug_msg("%s:%d:%s " fmt, __FILE__, __LINE__, __FUNCTION__, data1, data2)
56 #define DEBUG
57 #else
58 #define DEBUG_CRITICAL(fmt)
59 #define DEBUG_CRITICAL2(fmt, data)
60 #define DEBUG_CRITICAL3(fmt, data1, data2)
61 #endif
62
63 #ifdef DEBUG_LEVEL_INFO
64 #define DEBUG_INFO(fmt) debug_msg("%s:%d:%s " fmt, __FILE__, __LINE__, __FUNCTION__)
65 #define DEBUG_INFO2(fmt, data) debug_msg("%s:%d:%s " fmt, __FILE__, __LINE__, __FUNCTION__, data)
66 #define DEBUG_INFO3(fmt, data1, data2) debug_msg("%s:%d:%s " fmt, __FILE__, __LINE__, __FUNCTION__, data1, data2)
67 #define DEBUG_INFO4(fmt, data1, data2, data3) debug_msg("%s:%d:%s " fmt, __FILE__, __LINE__, __FUNCTION__, data1, data2, data3)
68 #define DEBUG
69 #else
70 #define DEBUG_INFO(fmt)
71 #define DEBUG_INFO2(fmt, data)
72 #define DEBUG_INFO3(fmt, data1, data2)
73 #define DEBUG_INFO4(fmt, data1, data2, data3)
74 #endif
75
76 #ifdef DEBUG_LEVEL_PERIODIC
77 #define DEBUG_PERIODIC(fmt) debug_msg("%s:%d:%s " fmt, __FILE__, __LINE__, __FUNCTION__)
78 #define DEBUG_PERIODIC2(fmt, data) debug_msg("%s:%d:%s " fmt, __FILE__, __LINE__, __FUNCTION__, data)
79 #define DEBUG
80 #else
81 #define DEBUG_PERIODIC(fmt)
82 #define DEBUG_PERIODIC2(fmt, data)
83 #endif
84
85 #ifdef DEBUG_LEVEL_COMM
86 #define DEBUG_COMM(fmt) debug_msg("%s:%d:%s " fmt, __FILE__, __LINE__, __FUNCTION__)
87 #define DEBUG_COMM2(fmt, data) debug_msg("%s:%d:%s " fmt, __FILE__, __LINE__, __FUNCTION__, data)
88 #define DEBUG_COMM3(fmt, data1, data2) debug_msg("%s:%d:%s " fmt, __FILE__, __LINE__, __FUNCTION__, data1, data2)
89 #define DEBUG
90 #define DEBUG_XXD(msg, buffer, size) debug_xxd(msg, buffer, size)
91 #else
92 #define DEBUG_COMM(fmt)
93 #define DEBUG_COMM2(fmt, data)
94 #define DEBUG_COMM3(fmt, data1, data2)
95 #endif
96
97 #ifndef DEBUG_XXD
98 #define DEBUG_XXD(msg, buffer, size)
99 #endif
100
101 void debug_msg(char *fmt, ...);
102 void debug_xxd(const char *msg, const unsigned char *buffer, const int size);
103
104 #endif
105

Properties

Name Value
svn:eol-style native
svn:keywords Author Date Id Revision

  ViewVC Help
Powered by ViewVC 1.1.5