nvme_ctrl_find;
nvme_ctrl_get_src_addr;
nvme_ctrl_release_fd;
+ nvme_get_debug;
nvme_get_features_err_recovery2;
nvme_get_features_host_mem_buf2;
nvme_get_features_iocs_profile;
nvme_host_release_fds;
nvme_ns_release_fd;
nvme_root_release_fds;
+ nvme_set_debug;
nvme_set_features_iocs_profile;
nvme_set_features_resv_mask2;
nvme_set_features_resv_persist2;
nvme_set_features_write_protect2;
+ nvme_set_root;
nvme_subsystem_get_iopolicy;
nvme_subsystem_release_fds;
- nvme_set_debug;
- nvme_get_debug;
};
LIBNVME_1_5 {
#define LOG_CLOCK CLOCK_MONOTONIC
#endif
+static nvme_root_t root;
+
void __attribute__((format(printf, 4, 5)))
__nvme_msg(nvme_root_t r, int lvl,
const char *func, const char *format, ...)
{
- FILE *fp = r ? r->fp : stderr;
+ FILE *fp = stderr;
va_list ap;
char pidbuf[16];
char timebuf[32];
char *message __cleanup__(cleanup_charp) = NULL;
int idx = 0;
+ if (!r)
+ r = root;
+
+ if (r)
+ fp = r->fp;
+
if (r && lvl > r->log_level)
return;
r->log_pid = log_pid;
r->log_timestamp = log_tstamp;
}
+
+void nvme_set_root(nvme_root_t r)
+{
+ root = r;
+}
*/
void nvme_init_logging(nvme_root_t r, int lvl, bool log_pid, bool log_tstamp);
+/**
+ * nvme_set_root() - Set nvme_root_t context
+ * @r: nvme_root_t context
+ *
+ * In order to be able to log from code paths where no root object is passed in
+ * via the arguments use the the default one which can be set via this call.
+ * When creating a new root object with @nvme_create_root the global root object
+ * will be set as well. This means the global root object is always pointing to
+ * the latest created root object. Note the first @nvme_free_tree call will reset
+ * the global root object.
+ */
+void nvme_set_root(nvme_root_t r);
+
#endif /* _LOG_H */
r->fp = fp;
list_head_init(&r->hosts);
list_head_init(&r->endpoints);
+ nvme_set_root(r);
return r;
}
free(r->config_file);
if (r->application)
free(r->application);
+ nvme_set_root(NULL);
free(r);
}