pcsc-lite
1.7.4
|
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 5714 2011-05-05 09:26:47Z 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 #ifdef NO_LOG 00064 00065 #define Log0(priority) do { } while(0) 00066 #define Log1(priority, fmt) do { } while(0) 00067 #define Log2(priority, fmt, data) do { } while(0) 00068 #define Log3(priority, fmt, data1, data2) do { } while(0) 00069 #define Log4(priority, fmt, data1, data2, data3) do { } while(0) 00070 #define Log5(priority, fmt, data1, data2, data3, data4) do { } while(0) 00071 #define Log9(priority, fmt, data1, data2, data3, data4, data5, data6, data7, data8) do { } while(0) 00072 #define LogXxd(priority, msg, buffer, size) do { } while(0) 00073 00074 #define DebugLogA(a) 00075 #define DebugLogB(a, b) 00076 #define DebugLogC(a, b,c) 00077 00078 #else 00079 00080 #define Log0(priority) log_msg(priority, "%s:%d:%s()", __FILE__, __LINE__, __FUNCTION__) 00081 #define Log1(priority, fmt) log_msg(priority, "%s:%d:%s() " fmt, __FILE__, __LINE__, __FUNCTION__) 00082 #define Log2(priority, fmt, data) log_msg(priority, "%s:%d:%s() " fmt, __FILE__, __LINE__, __FUNCTION__, data) 00083 #define Log3(priority, fmt, data1, data2) log_msg(priority, "%s:%d:%s() " fmt, __FILE__, __LINE__, __FUNCTION__, data1, data2) 00084 #define Log4(priority, fmt, data1, data2, data3) log_msg(priority, "%s:%d:%s() " fmt, __FILE__, __LINE__, __FUNCTION__, data1, data2, data3) 00085 #define Log5(priority, fmt, data1, data2, data3, data4) log_msg(priority, "%s:%d:%s() " fmt, __FILE__, __LINE__, __FUNCTION__, data1, data2, data3, data4) 00086 #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) 00087 #define LogXxd(priority, msg, buffer, size) log_xxd(priority, msg, buffer, size) 00088 00089 #define DebugLogA(a) Log1(PCSC_LOG_INFO, a) 00090 #define DebugLogB(a, b) Log2(PCSC_LOG_INFO, a, b) 00091 #define DebugLogC(a, b,c) Log3(PCSC_LOG_INFO, a, b, c) 00092 00093 #endif /* NO_LOG */ 00094 00095 PCSC_API void log_msg(const int priority, const char *fmt, ...); 00096 PCSC_API void log_xxd(const int priority, const char *msg, 00097 const unsigned char *buffer, const int size); 00098 00099 void DebugLogSuppress(const int); 00100 void DebugLogSetLogType(const int); 00101 int DebugLogSetCategory(const int); 00102 void DebugLogCategory(const int, const unsigned char *, const int); 00103 PCSC_API void DebugLogSetLevel(const int level); 00104 00105 #endif /* __debuglog_h__ */ 00106