summaryrefslogtreecommitdiffstats
path: root/src/nvme/log.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/nvme/log.c')
-rw-r--r--src/nvme/log.c25
1 files changed, 25 insertions, 0 deletions
diff --git a/src/nvme/log.c b/src/nvme/log.c
index 2ffca3e..c98d213 100644
--- a/src/nvme/log.c
+++ b/src/nvme/log.c
@@ -58,6 +58,8 @@ __nvme_msg(nvme_root_t r, int lvl,
if (r && lvl > r->log_level)
return;
+ if (!r && lvl > DEFAULT_LOGLEVEL)
+ return;
if (r && r->log_timestamp) {
struct timespec now;
@@ -99,7 +101,30 @@ void nvme_init_logging(nvme_root_t r, int lvl, bool log_pid, bool log_tstamp)
r->log_timestamp = log_tstamp;
}
+int nvme_get_logging_level(nvme_root_t r, bool *log_pid, bool *log_tstamp)
+{
+ if (!r)
+ r = root;
+ if (!r)
+ return DEFAULT_LOGLEVEL;
+ if (log_pid)
+ *log_pid = r->log_pid;
+ if (log_tstamp)
+ *log_tstamp = r->log_timestamp;
+ return r->log_level;
+}
+
void nvme_set_root(nvme_root_t r)
{
root = r;
}
+
+void nvme_set_debug(bool debug)
+{
+ root->log_level = debug ? LOG_DEBUG : DEFAULT_LOGLEVEL;
+}
+
+bool nvme_get_debug(void)
+{
+ return root->log_level == LOG_DEBUG;
+}