pcsc-lite  1.8.8
debuglog.h
Go to the documentation of this file.
1 /*
2  * MUSCLE SmartCard Development ( http://www.linuxnet.com )
3  *
4  * Copyright (C) 1999-2004
5  * David Corcoran <corcoran@linuxnet.com>
6  * Copyright (C) 1999-2011
7  * Ludovic Rousseau <ludovic.rousseau@free.fr>
8  *
9  * $Id: debuglog.h 5854 2011-07-09 11:10:32Z rousseau $
10  */
11 
33 #ifndef __debuglog_h__
34 #define __debuglog_h__
35 
36 #ifndef PCSC_API
37 #define PCSC_API
38 #endif
39 
40 enum {
41  DEBUGLOG_NO_DEBUG = 0,
42  DEBUGLOG_SYSLOG_DEBUG,
43  DEBUGLOG_STDOUT_DEBUG,
44  DEBUGLOG_STDOUT_COLOR_DEBUG
45 };
46 
47 #define DEBUG_CATEGORY_NOTHING 0
48 #define DEBUG_CATEGORY_APDU 1
49 #define DEBUG_CATEGORY_SW 2
50 
51 enum {
52  PCSC_LOG_DEBUG = 0,
53  PCSC_LOG_INFO,
54  PCSC_LOG_ERROR,
55  PCSC_LOG_CRITICAL
56 };
57 
58 /* You can't do #ifndef __FUNCTION__ */
59 #if !defined(__GNUC__) && !defined(__IBMC__)
60 #define __FUNCTION__ ""
61 #endif
62 
63 #ifndef __GNUC__
64 #define __attribute__(x) /*nothing*/
65 #endif
66 
67 #ifdef NO_LOG
68 
69 #define Log0(priority) do { } while(0)
70 #define Log1(priority, fmt) do { } while(0)
71 #define Log2(priority, fmt, data) do { } while(0)
72 #define Log3(priority, fmt, data1, data2) do { } while(0)
73 #define Log4(priority, fmt, data1, data2, data3) do { } while(0)
74 #define Log5(priority, fmt, data1, data2, data3, data4) do { } while(0)
75 #define Log9(priority, fmt, data1, data2, data3, data4, data5, data6, data7, data8) do { } while(0)
76 #define LogXxd(priority, msg, buffer, size) do { } while(0)
77 
78 #define DebugLogA(a)
79 #define DebugLogB(a, b)
80 #define DebugLogC(a, b,c)
81 
82 #else
83 
84 #define Log0(priority) log_msg(priority, "%s:%d:%s()", __FILE__, __LINE__, __FUNCTION__)
85 #define Log1(priority, fmt) log_msg(priority, "%s:%d:%s() " fmt, __FILE__, __LINE__, __FUNCTION__)
86 #define Log2(priority, fmt, data) log_msg(priority, "%s:%d:%s() " fmt, __FILE__, __LINE__, __FUNCTION__, data)
87 #define Log3(priority, fmt, data1, data2) log_msg(priority, "%s:%d:%s() " fmt, __FILE__, __LINE__, __FUNCTION__, data1, data2)
88 #define Log4(priority, fmt, data1, data2, data3) log_msg(priority, "%s:%d:%s() " fmt, __FILE__, __LINE__, __FUNCTION__, data1, data2, data3)
89 #define Log5(priority, fmt, data1, data2, data3, data4) log_msg(priority, "%s:%d:%s() " fmt, __FILE__, __LINE__, __FUNCTION__, data1, data2, data3, data4)
90 #define Log9(priority, fmt, data1, data2, data3, data4, data5, data6, data7, data8) log_msg(priority, "%s:%d:%s() " fmt, __FILE__, __LINE__, __FUNCTION__, data1, data2, data3, data4, data5, data6, data7, data8)
91 #define LogXxd(priority, msg, buffer, size) log_xxd(priority, msg, buffer, size)
92 
93 #define DebugLogA(a) Log1(PCSC_LOG_INFO, a)
94 #define DebugLogB(a, b) Log2(PCSC_LOG_INFO, a, b)
95 #define DebugLogC(a, b,c) Log3(PCSC_LOG_INFO, a, b, c)
96 
97 #endif /* NO_LOG */
98 
99 PCSC_API void log_msg(const int priority, const char *fmt, ...)
100  __attribute__((format(printf, 2, 3)));
101 
102 PCSC_API void log_xxd(const int priority, const char *msg,
103  const unsigned char *buffer, const int size);
104 
105 void DebugLogSuppress(const int);
106 void DebugLogSetLogType(const int);
107 int DebugLogSetCategory(const int);
108 void DebugLogCategory(const int, const unsigned char *, const int);
109 PCSC_API void DebugLogSetLevel(const int level);
110 
111 #endif /* __debuglog_h__ */
112