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.c19
1 files changed, 16 insertions, 3 deletions
diff --git a/src/nvme/log.c b/src/nvme/log.c
index e4697df..2ffca3e 100644
--- a/src/nvme/log.c
+++ b/src/nvme/log.c
@@ -26,11 +26,13 @@
#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];
@@ -44,10 +46,16 @@ __nvme_msg(nvme_root_t r, int lvl,
"[%s] <%s>%s ",
"[%s] <%s> %s: ",
};
- char *header __cleanup__(cleanup_charp) = NULL;
- char *message __cleanup__(cleanup_charp) = NULL;
+ _cleanup_free_ char *header = NULL;
+ _cleanup_free_ char *message = NULL;
int idx = 0;
+ if (!r)
+ r = root;
+
+ if (r)
+ fp = r->fp;
+
if (r && lvl > r->log_level)
return;
@@ -90,3 +98,8 @@ void nvme_init_logging(nvme_root_t r, int lvl, bool log_pid, bool log_tstamp)
r->log_pid = log_pid;
r->log_timestamp = log_tstamp;
}
+
+void nvme_set_root(nvme_root_t r)
+{
+ root = r;
+}