Add a logging subsystem and change all DPRINTF to ISCSI_LOG

Add a mechanism where we can set a logging subsystem that libiscsi can use.
Create an example 'log to stderr' that utilities can use for convenience.
This commit is contained in:
Ronnie Sahlberg
2012-11-07 06:34:38 -08:00
parent c10ae3ae3e
commit 50e7c682bb
13 changed files with 134 additions and 51 deletions

View File

@@ -127,7 +127,9 @@ struct iscsi_context {
int lun;
int no_auto_reconnect;
int reconnect_deferred;
int debug;
int log_level;
iscsi_log_fn log_fn;
};
#define ISCSI_PDU_IMMEDIATE 0x40
@@ -284,6 +286,16 @@ struct scsi_task *iscsi_scsi_get_task_from_pdu(struct iscsi_pdu *pdu);
void iscsi_set_noautoreconnect(struct iscsi_context *iscsi, int state);
#define ISCSI_LOG(iscsi, level, format, args...) \
do { \
if (level <= iscsi->log_level && iscsi->log_fn) { \
iscsi_log_message(iscsi, level, format, ## args); \
} \
} while (0)
void
iscsi_log_message(struct iscsi_context *iscsi, int level, const char *format, ...);
#ifdef __cplusplus
}
#endif