00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00033 #ifndef __debuglog_h__
00034 #define __debuglog_h__
00035
00036 #ifdef __cplusplus
00037 extern "C"
00038 {
00039 #endif
00040
00041 #ifndef PCSC_API
00042 #define PCSC_API
00043 #endif
00044
00045 #define DEBUGLOG_LOG_ENTRIES 1
00046 #define DEBUGLOG_IGNORE_ENTRIES 2
00047
00048 enum {
00049 DEBUGLOG_NO_DEBUG = 0,
00050 DEBUGLOG_SYSLOG_DEBUG,
00051 DEBUGLOG_STDERR_DEBUG
00052 };
00053
00054 #define DEBUG_CATEGORY_NOTHING 0
00055 #define DEBUG_CATEGORY_APDU 1
00056 #define DEBUG_CATEGORY_SW 2
00057
00058 enum {
00059 PCSC_LOG_DEBUG = 0,
00060 PCSC_LOG_INFO,
00061 PCSC_LOG_ERROR,
00062 PCSC_LOG_CRITICAL
00063 };
00064
00065
00066 #if !defined(__GNUC__) && !defined(__IBMC__)
00067 #define __FUNCTION__ ""
00068 #endif
00069
00070 #ifdef NO_LOG
00071
00072 #define Log0(priority) do { } while(0)
00073 #define Log1(priority, fmt) do { } while(0)
00074 #define Log2(priority, fmt, data) do { } while(0)
00075 #define Log3(priority, fmt, data1, data2) do { } while(0)
00076 #define Log4(priority, fmt, data1, data2, data3) do { } while(0)
00077 #define Log9(priority, fmt, data1, data2, data3, data4, data5, data6, data7, data8) do { } while(0)
00078 #define LogXxd(priority, msg, buffer, size) do { } while(0)
00079
00080 #define DebugLogA(a)
00081 #define DebugLogB(a, b)
00082 #define DebugLogC(a, b,c)
00083
00084 #else
00085
00086 #define Log0(priority) log_msg(priority, "%s:%d:%s()", __FILE__, __LINE__, __FUNCTION__)
00087 #define Log1(priority, fmt) log_msg(priority, "%s:%d:%s() " fmt, __FILE__, __LINE__, __FUNCTION__)
00088 #define Log2(priority, fmt, data) log_msg(priority, "%s:%d:%s() " fmt, __FILE__, __LINE__, __FUNCTION__, data)
00089 #define Log3(priority, fmt, data1, data2) log_msg(priority, "%s:%d:%s() " fmt, __FILE__, __LINE__, __FUNCTION__, data1, data2)
00090 #define Log4(priority, fmt, data1, data2, data3) log_msg(priority, "%s:%d:%s() " fmt, __FILE__, __LINE__, __FUNCTION__, data1, data2, data3)
00091 #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)
00092 #define LogXxd(priority, msg, buffer, size) log_xxd(priority, msg, buffer, size)
00093
00094 #define DebugLogA(a) Log1(PCSC_LOG_INFO, a)
00095 #define DebugLogB(a, b) Log2(PCSC_LOG_INFO, a, b)
00096 #define DebugLogC(a, b,c) Log3(PCSC_LOG_INFO, a, b, c)
00097
00098 #endif
00099
00100 PCSC_API void log_msg(const int priority, const char *fmt, ...);
00101 PCSC_API void log_xxd(const int priority, const char *msg,
00102 const unsigned char *buffer, const int size);
00103
00104 void DebugLogSuppress(const int);
00105 void DebugLogSetLogType(const int);
00106 int DebugLogSetCategory(const int);
00107 void DebugLogCategory(const int, const unsigned char *, const int);
00108 PCSC_API void DebugLogSetLevel(const int level);
00109
00110 #ifdef __cplusplus
00111 }
00112 #endif
00113
00114 #endif
00115