summaryrefslogtreecommitdiffstats
path: root/util/log.h
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2021-07-02 20:47:46 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2021-07-02 20:47:46 +0000
commit5b7ddc4bd2dcdde201ffa2681ede9a0a029bad96 (patch)
tree352b477f97c1c36105310589c7568259c76e9385 /util/log.h
parentAdding upstream version 1.12. (diff)
downloadnvme-cli-d0345ae9d4ce43c4bed3383b62fdefafd2dde0fa.tar.xz
nvme-cli-d0345ae9d4ce43c4bed3383b62fdefafd2dde0fa.zip
Adding upstream version 1.14.upstream/1.14
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'util/log.h')
-rw-r--r--util/log.h34
1 files changed, 34 insertions, 0 deletions
diff --git a/util/log.h b/util/log.h
new file mode 100644
index 0000000..15107a5
--- /dev/null
+++ b/util/log.h
@@ -0,0 +1,34 @@
+/*
+ * Copyright (c) 2021 Martin Wilck, SUSE LLC
+ * SPDX-License-Identifier: LGPL-2.1-or-newer
+ */
+#ifndef _LOG_H
+#define _LOG_H
+
+#ifndef MAX_LOGLEVEL
+# define MAX_LOGLEVEL LOG_DEBUG
+#endif
+#ifndef DEFAULT_LOGLEVEL
+# define DEFAULT_LOGLEVEL LOG_NOTICE
+#endif
+
+#if (LOG_FUNCNAME == 1)
+#define _log_func __func__
+#else
+#define _log_func NULL
+#endif
+
+extern int log_level;
+extern bool log_timestamp;
+extern bool log_pid;
+
+void __attribute__((format(printf, 3, 4)))
+__msg(int lvl, const char *func, const char *format, ...);
+
+#define msg(lvl, format, ...) \
+ do { \
+ if ((lvl) <= MAX_LOGLEVEL) \
+ __msg(lvl, _log_func, format, ##__VA_ARGS__); \
+ } while (0)
+
+#endif /* _LOG_H */