pcsc-lite
1.8.2
|
00001 /* 00002 * MUSCLE SmartCard Development ( http://www.linuxnet.com ) 00003 * 00004 * Copyright (C) 1999-2004 00005 * David Corcoran <corcoran@linuxnet.com> 00006 * Copyright (C) 1999-2011 00007 * Ludovic Rousseau <ludovic.rousseau@free.fr> 00008 * 00009 * $Id: debuglog.h 5854 2011-07-09 11:10:32Z rousseau $ 00010 */ 00011 00033 #ifndef __debuglog_h__ 00034 #define __debuglog_h__ 00035 00036 #ifndef PCSC_API 00037 #define PCSC_API 00038 #endif 00039 00040 enum { 00041 DEBUGLOG_NO_DEBUG = 0, 00042 DEBUGLOG_SYSLOG_DEBUG, 00043 DEBUGLOG_STDOUT_DEBUG, 00044 DEBUGLOG_STDOUT_COLOR_DEBUG 00045 }; 00046 00047 #define DEBUG_CATEGORY_NOTHING 0 00048 #define DEBUG_CATEGORY_APDU 1 00049 #define DEBUG_CATEGORY_SW 2 00050 00051 enum { 00052 PCSC_LOG_DEBUG = 0, 00053 PCSC_LOG_INFO, 00054 PCSC_LOG_ERROR, 00055 PCSC_LOG_CRITICAL 00056 }; 00057 00058 /* You can't do #ifndef __FUNCTION__ */ 00059 #if !defined(__GNUC__) && !defined(__IBMC__) 00060 #define __FUNCTION__ "" 00061 #endif 00062 00063 #ifndef __GNUC__ 00064 #define __attribute__(x) /*nothing*/ 00065 #endif 00066 00067 #ifdef NO_LOG 00068 00069 #define Log0(priority) do { } while(0) 00070 #define Log1(priority, fmt) do { } while(0) 00071 #define Log2(priority, fmt, data) do { } while(0) 00072 #define Log3(priority, fmt, data1, data2) do { } while(0) 00073 #define Log4(priority, fmt, data1, data2, data3) do { } while(0) 00074 #define Log5(priority, fmt, data1, data2, data3, data4) do { } while(0) 00075 #define Log9(priority, fmt, data1, data2, data3, data4, data5, data6, data7, data8) do { } while(0) 00076 #define LogXxd(priority, msg, buffer, size) do { } while(0) 00077 00078 #define DebugLogA(a) 00079 #define DebugLogB(a, b) 00080 #define DebugLogC(a, b,c) 00081 00082 #else 00083 00084 #define Log0(priority) log_msg(priority, "%s:%d:%s()", __FILE__, __LINE__, __FUNCTION__) 00085 #define Log1(priority, fmt) log_msg(priority, "%s:%d:%s() " fmt, __FILE__, __LINE__, __FUNCTION__) 00086 #define Log2(priority, fmt, data) log_msg(priority, "%s:%d:%s() " fmt, __FILE__, __LINE__, __FUNCTION__, data) 00087 #define Log3(priority, fmt, data1, data2) log_msg(priority, "%s:%d:%s() " fmt, __FILE__, __LINE__, __FUNCTION__, data1, data2) 00088 #define Log4(priority, fmt, data1, data2, data3) log_msg(priority, "%s:%d:%s() " fmt, __FILE__, __LINE__, __FUNCTION__, data1, data2, data3) 00089 #define Log5(priority, fmt, data1, data2, data3, data4) log_msg(priority, "%s:%d:%s() " fmt, __FILE__, __LINE__, __FUNCTION__, data1, data2, data3, data4) 00090 #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) 00091 #define LogXxd(priority, msg, buffer, size) log_xxd(priority, msg, buffer, size) 00092 00093 #define DebugLogA(a) Log1(PCSC_LOG_INFO, a) 00094 #define DebugLogB(a, b) Log2(PCSC_LOG_INFO, a, b) 00095 #define DebugLogC(a, b,c) Log3(PCSC_LOG_INFO, a, b, c) 00096 00097 #endif /* NO_LOG */ 00098 00099 PCSC_API void log_msg(const int priority, const char *fmt, ...) 00100 __attribute__((format(printf, 2, 3))); 00101 00102 PCSC_API void log_xxd(const int priority, const char *msg, 00103 const unsigned char *buffer, const int size); 00104 00105 void DebugLogSuppress(const int); 00106 void DebugLogSetLogType(const int); 00107 int DebugLogSetCategory(const int); 00108 void DebugLogCategory(const int, const unsigned char *, const int); 00109 PCSC_API void DebugLogSetLevel(const int level); 00110 00111 #endif /* __debuglog_h__ */ 00112