| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
|
| 23 |
|
| 24 |
|
| 25 |
|
| 26 |
|
| 27 |
|
| 28 |
#ifndef ISTGT_LOG_H |
| 29 |
#define ISTGT_LOG_H |
| 30 |
|
| 31 |
#include <stdint.h> |
| 32 |
#include <stddef.h> |
| 33 |
|
| 34 |
#ifndef ISTGT_LOG_FACILITY |
| 35 |
#define ISTGT_LOG_FACILITY LOG_LOCAL7 |
| 36 |
#endif |
| 37 |
#ifndef ISTGT_LOG_PRIORITY |
| 38 |
#define ISTGT_LOG_PRIORITY LOG_NOTICE |
| 39 |
#endif |
| 40 |
|
| 41 |
#define ISTGT_TRACE_ALL (~0U) |
| 42 |
#define ISTGT_TRACE_NONE 0U |
| 43 |
#define ISTGT_TRACE_DEBUG 0x80000000U |
| 44 |
#define ISTGT_TRACE_NET 0x0000000fU |
| 45 |
#define ISTGT_TRACE_ISCSI 0x000000f0U |
| 46 |
#define ISTGT_TRACE_SCSI 0x00000f00U |
| 47 |
#define ISTGT_TRACE_LU 0x0000f000U |
| 48 |
|
| 49 |
#define ISTGT_LOG(...) \ |
| 50 |
istgt_log(NULL, 0, NULL, __VA_ARGS__) |
| 51 |
#define ISTGT_NOTICELOG(...) \ |
| 52 |
istgt_noticelog(NULL, 0, NULL, __VA_ARGS__) |
| 53 |
#define ISTGT_ERRLOG(...) \ |
| 54 |
istgt_errlog(__FILE__, __LINE__, __func__, __VA_ARGS__) |
| 55 |
#define ISTGT_WARNLOG(...) \ |
| 56 |
do { \ |
| 57 |
if (g_warn_flag != 0) { \ |
| 58 |
istgt_warnlog(__FILE__, __LINE__, __func__, __VA_ARGS__); \ |
| 59 |
} \ |
| 60 |
} while (0) |
| 61 |
#ifdef DEBUG |
| 62 |
#define ISTGT_TRACELOG(FLAG, ...) \ |
| 63 |
do { \ |
| 64 |
if (g_trace_flag & (FLAG)) { \ |
| 65 |
istgt_tracelog((FLAG), __FILE__, __LINE__, __func__, \ |
| 66 |
__VA_ARGS__); \ |
| 67 |
} \ |
| 68 |
} while (0) |
| 69 |
#define ISTGT_TRACEDUMP(FLAG, LABEL, BUF, LEN) \ |
| 70 |
do { \ |
| 71 |
if (g_trace_flag & (FLAG)) { \ |
| 72 |
istgt_trace_dump((FLAG), (LABEL), (BUF), (LEN)); \ |
| 73 |
} \ |
| 74 |
} while (0) |
| 75 |
#else |
| 76 |
#define ISTGT_TRACELOG(FLAG, ...) |
| 77 |
#define ISTGT_TRACEDUMP(FLAG, LABEL, BUF, LEN) |
| 78 |
#endif |
| 79 |
|
| 80 |
int istgt_set_log_facility(const char *facility); |
| 81 |
int istgt_set_log_priority(const char *priority); |
| 82 |
void istgt_log(const char *file, const int line, const char *func, const char *format, ...); |
| 83 |
void istgt_noticelog(const char *file, const int line, const char *func, const char *format, ...); |
| 84 |
void istgt_tracelog(const int flag, const char *file, const int line, const char *func, const char *format, ...); |
| 85 |
void istgt_errlog(const char *file, const int line, const char *func, const char *format, ...); |
| 86 |
void istgt_warnlog(const char *file, const int line, const char *func, const char *format, ...); |
| 87 |
void istgt_open_log(void); |
| 88 |
void istgt_close_log(void); |
| 89 |
void istgt_set_trace_flag(int flag); |
| 90 |
void istgt_trace_dump(int flag, const char *label, const uint8_t *buf, size_t len); |
| 91 |
|
| 92 |
extern int g_trace_flag; |
| 93 |
extern int g_warn_flag; |
| 94 |
|
| 95 |
#endif |