summaryrefslogtreecommitdiff
path: root/include/log.h
diff options
context:
space:
mode:
authoremersion <contact@emersion.fr>2019-01-15 09:16:06 +0100
committerGitHub <noreply@github.com>2019-01-15 09:16:06 +0100
commit56b672a16c248c268fde17243a914a3bcfa4ac47 (patch)
tree01a33b3422b9d17ad3b63fb4decb972876210f88 /include/log.h
parentfcf1bd4ebea97ae6ecd30e4f4e0c526b405b871a (diff)
parente3935ad1431623b5e3966e95cd75b45e7e00e278 (diff)
Merge pull request #7 from RedSoxFan/remove-wlroots
Implement logging and remove wlroots dependency
Diffstat (limited to 'include/log.h')
-rw-r--r--include/log.h36
1 files changed, 36 insertions, 0 deletions
diff --git a/include/log.h b/include/log.h
new file mode 100644
index 0000000..fc3747a
--- /dev/null
+++ b/include/log.h
@@ -0,0 +1,36 @@
+#ifndef _SWAYLOCK_LOG_H
+#define _SWAYLOCK_LOG_H
+
+#include <stdarg.h>
+#include <string.h>
+#include <errno.h>
+
+enum log_importance {
+ LOG_SILENT = 0,
+ LOG_ERROR = 1,
+ LOG_INFO = 2,
+ LOG_DEBUG = 3,
+ LOG_IMPORTANCE_LAST,
+};
+
+void swaylock_log_init(enum log_importance verbosity);
+
+#ifdef __GNUC__
+#define _ATTRIB_PRINTF(start, end) __attribute__((format(printf, start, end)))
+#else
+#define _ATTRIB_PRINTF(start, end)
+#endif
+
+void _swaylock_log(enum log_importance verbosity, const char *format, ...)
+ _ATTRIB_PRINTF(2, 3);
+
+const char *_swaylock_strip_path(const char *filepath);
+
+#define swaylock_log(verb, fmt, ...) \
+ _swaylock_log(verb, "[%s:%d] " fmt, _swaylock_strip_path(__FILE__), \
+ __LINE__, ##__VA_ARGS__)
+
+#define swaylock_log_errno(verb, fmt, ...) \
+ swaylock_log(verb, fmt ": %s", ##__VA_ARGS__, strerror(errno))
+
+#endif