diff options
author | Wenchao Hao <haowenchao@huawei.com> | 2022-01-29 15:41:41 +0800 |
---|---|---|
committer | Wenchao Hao <haowenchao@huawei.com> | 2022-02-25 17:26:35 +0800 |
commit | ed5ddbb68d23599a065568f0f47e4cd175dbe01b (patch) | |
tree | 9c5dde152f5014b3a6de5c665c352587f5ca5a09 /usr | |
parent | eb44b45eb53cd8c1c46110aab6cfe86e390f237c (diff) | |
download | open-iscsi-ed5ddbb68d23599a065568f0f47e4cd175dbe01b.tar.gz |
Add conn_xxx() macros to print connection info in more details
conn_info() conn_warn() conn_error() and conn_debug() are added.
conn_xxx() macros would print session id and connection id in log.
Signed-off-by: Wenchao Hao <haowenchao@huawei.com>
Diffstat (limited to 'usr')
-rw-r--r-- | usr/initiator.h | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/usr/initiator.h b/usr/initiator.h index dbf6f2b..a4e01a2 100644 --- a/usr/initiator.h +++ b/usr/initiator.h @@ -32,6 +32,7 @@ #include "config.h" #include "actor.h" #include "list.h" +#include "log.h" #define ISCSI_CONFIG_ROOT "/etc/iscsi/" @@ -45,6 +46,46 @@ #define LOCK_FILE LOCK_DIR"/lock" #define LOCK_WRITE_FILE LOCK_DIR"/lock.write" +#define conn_info(conn, fmt, ...) \ +do { \ + if (conn->session == NULL) { \ + log_info(fmt, ##__VA_ARGS__); \ + break; \ + } \ + log_info("connection%d:%d " fmt, \ + conn->session->id, conn->id, ##__VA_ARGS__); \ +} while(0) + +#define conn_warn(conn, fmt, ...) \ +do { \ + if (conn->session == NULL) { \ + log_warning(fmt, ##__VA_ARGS__); \ + break; \ + } \ + log_warning("connection%d:%d " fmt, \ + conn->session->id, conn->id, ##__VA_ARGS__); \ +} while(0) + +#define conn_error(conn, fmt, ...) \ +do { \ + if (conn->session == NULL) { \ + log_error(fmt, ##__VA_ARGS__); \ + break; \ + } \ + log_error("connection%d:%d " fmt, \ + conn->session->id, conn->id, ##__VA_ARGS__); \ +} while(0) + +#define conn_debug(level, conn, fmt, ...) \ +do { \ + if (conn->session == NULL) { \ + log_debug(level, fmt, ##__VA_ARGS__); \ + break; \ + } \ + log_debug(level, "connection%d:%d " fmt, \ + conn->session->id, conn->id, ##__VA_ARGS__); \ +} while(0) + typedef enum iscsi_session_r_stage_e { R_STAGE_NO_CHANGE, R_STAGE_SESSION_CLEANUP, |