changed protocoll to use 2 byte length
[nfcbtpcsc.git] / debuglog.h
blob75b22be1a1e767dff7e0105d92bef2e0392222bb
1 /*
2 * MUSCLE SmartCard Development ( http://www.linuxnet.com )
4 * Copyright (C) 1999-2004
5 * David Corcoran <corcoran@linuxnet.com>
6 * Copyright (C) 1999-2005
7 * Ludovic Rousseau <ludovic.rousseau@free.fr>
9 * $Id: debuglog.h 3075 2008-07-30 14:25:27Z rousseau $
12 /**
13 * @file
14 * @brief This handles debugging.
16 * @note log message is sent to syslog or stderr depending on --foreground
17 * command line argument
19 * @code
20 * Log1(priority, "text");
21 * log "text" with priority level priority
22 * Log2(priority, "text: %d", 1234);
23 * log "text: 1234"
24 * the format string can be anything printf() can understand
25 * Log3(priority, "text: %d %d", 1234, 5678);
26 * log "text: 1234 5678"
27 * the format string can be anything printf() can understand
28 * LogXxd(priority, msg, buffer, size);
29 * log "msg" + a hex dump of size bytes of buffer[]
30 * @endcode
33 #ifndef __debuglog_h__
34 #define __debuglog_h__
36 #ifdef __cplusplus
37 extern "C"
39 #endif
41 #ifndef PCSC_API
42 #define PCSC_API
43 #endif
45 #define DEBUGLOG_LOG_ENTRIES 1
46 #define DEBUGLOG_IGNORE_ENTRIES 2
48 enum {
49 DEBUGLOG_NO_DEBUG = 0,
50 DEBUGLOG_SYSLOG_DEBUG,
51 DEBUGLOG_STDERR_DEBUG
54 #define DEBUG_CATEGORY_NOTHING 0
55 #define DEBUG_CATEGORY_APDU 1
56 #define DEBUG_CATEGORY_SW 2
58 enum {
59 PCSC_LOG_DEBUG = 0,
60 PCSC_LOG_INFO,
61 PCSC_LOG_ERROR,
62 PCSC_LOG_CRITICAL
65 /* You can't do #ifndef __FUNCTION__ */
66 #if !defined(__GNUC__) && !defined(__IBMC__)
67 #define __FUNCTION__ ""
68 #endif
70 #define Log0(priority) log_msg(priority, "%s:%d:%s()", __FILE__, __LINE__, __FUNCTION__)
71 #define Log1(priority, fmt) log_msg(priority, "%s:%d:%s() " fmt, __FILE__, __LINE__, __FUNCTION__)
72 #define Log2(priority, fmt, data) log_msg(priority, "%s:%d:%s() " fmt, __FILE__, __LINE__, __FUNCTION__, data)
73 #define Log3(priority, fmt, data1, data2) log_msg(priority, "%s:%d:%s() " fmt, __FILE__, __LINE__, __FUNCTION__, data1, data2)
74 #define Log4(priority, fmt, data1, data2, data3) log_msg(priority, "%s:%d:%s() " fmt, __FILE__, __LINE__, __FUNCTION__, data1, data2, data3)
75 #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)
76 #define LogXxd(priority, msg, buffer, size) log_xxd(priority, msg, buffer, size)
78 #define DebugLogA(a) Log1(PCSC_LOG_INFO, a)
79 #define DebugLogB(a, b) Log2(PCSC_LOG_INFO, a, b)
80 #define DebugLogC(a, b,c) Log3(PCSC_LOG_INFO, a, b, c)
82 PCSC_API void log_msg(const int priority, const char *fmt, ...);
83 PCSC_API void log_xxd(const int priority, const char *msg,
84 const unsigned char *buffer, const int size);
86 void DebugLogSuppress(const int);
87 void DebugLogSetLogType(const int);
88 int DebugLogSetCategory(const int);
89 void DebugLogCategory(const int, const unsigned char *, const int);
90 PCSC_API void DebugLogSetLevel(const int level);
92 #ifdef __cplusplus
94 #endif
96 #endif /* __debuglog_h__ */