diff options
author | Drew DeVault <sir@cmpwn.com> | 2019-04-25 11:03:40 -0400 |
---|---|---|
committer | Drew DeVault <sir@cmpwn.com> | 2019-04-25 11:03:40 -0400 |
commit | 34e4a47a8675ad2183fb34b0f93699a5a3c21258 (patch) | |
tree | a05f189144d2758cc44d70bbea79fbe136c9bc48 /include/log.h | |
parent | 3ee910d46840771bf32bfd8776ff8bb25853d216 (diff) | |
download | swaybg-34e4a47a8675ad2183fb34b0f93699a5a3c21258.tar.gz swaybg-34e4a47a8675ad2183fb34b0f93699a5a3c21258.tar.bz2 |
Split swaybg into a standalone project
Diffstat (limited to '')
-rw-r--r-- | include/log.h | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/include/log.h b/include/log.h new file mode 100644 index 0000000..eaa265a --- /dev/null +++ b/include/log.h @@ -0,0 +1,36 @@ +#ifndef _SWAYBG_LOG_H +#define _SWAYBG_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 swaybg_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 _swaybg_log(enum log_importance verbosity, const char *format, ...) + _ATTRIB_PRINTF(2, 3); + +const char *_swaybg_strip_path(const char *filepath); + +#define swaybg_log(verb, fmt, ...) \ + _swaybg_log(verb, "[%s:%d] " fmt, _swaybg_strip_path(__FILE__), \ + __LINE__, ##__VA_ARGS__) + +#define swaybg_log_errno(verb, fmt, ...) \ + swaybg_log(verb, fmt ": %s", ##__VA_ARGS__, strerror(errno)) + +#endif |