Debian Codegraph @

src/istgt_log.h

raw symbols SCIP
1 /*
2 * Copyright (C) 2008-2010 Daisuke Aoyama <[email protected]>.
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
13 *
14 * THIS SOFTWARE IS PROVIDED BY AUTHOR AND CONTRIBUTORS ``AS IS'' AND
15 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
17 * ARE DISCLAIMED. IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE
18 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24 * SUCH DAMAGE.
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 /* DEBUG */
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 /* ISTGT_LOG_H */