2015-08-08 17:01:22 -04:00
|
|
|
#ifndef _SWAY_LOG_H
|
|
|
|
|
#define _SWAY_LOG_H
|
2018-05-24 21:43:56 +02:00
|
|
|
|
2018-01-05 22:32:51 +01:00
|
|
|
#include <wlr/util/log.h>
|
2018-05-24 21:43:56 +02:00
|
|
|
#include <stdbool.h>
|
|
|
|
|
#include <stdarg.h>
|
|
|
|
|
#include <string.h>
|
|
|
|
|
#include <errno.h>
|
2017-04-20 19:13:53 +03:00
|
|
|
|
2018-01-05 23:36:32 +01:00
|
|
|
void _sway_abort(const char *filename, ...) ATTRIB_PRINTF(1, 2);
|
2017-04-20 19:13:53 +03:00
|
|
|
#define sway_abort(FMT, ...) \
|
2018-05-24 21:43:56 +02:00
|
|
|
_sway_abort("[%s:%d] " FMT, sway_strip_path(__FILE__), __LINE__, ##__VA_ARGS__)
|
2015-08-26 11:01:26 -07:00
|
|
|
|
2018-01-05 23:36:32 +01:00
|
|
|
bool _sway_assert(bool condition, const char* format, ...) ATTRIB_PRINTF(2, 3);
|
2015-08-26 11:01:26 -07:00
|
|
|
#define sway_assert(COND, FMT, ...) \
|
2018-05-24 21:43:56 +02:00
|
|
|
_sway_assert(COND, "[%s:%d] %s:" FMT, sway_strip_path(__FILE__), __LINE__, __PRETTY_FUNCTION__, ##__VA_ARGS__)
|
2015-08-26 11:01:26 -07:00
|
|
|
|
2015-08-24 15:44:58 -05:00
|
|
|
void error_handler(int sig);
|
2015-08-08 17:01:22 -04:00
|
|
|
|
2018-05-24 21:43:56 +02:00
|
|
|
typedef void (*log_callback_t)(log_importance_t importance, const char *fmt, va_list args);
|
|
|
|
|
|
|
|
|
|
// Will log all messages less than or equal to `verbosity`
|
|
|
|
|
// If `callback` is NULL, sway will use its default logger.
|
|
|
|
|
void sway_log_init(log_importance_t verbosity, log_callback_t callback);
|
|
|
|
|
|
|
|
|
|
void _sway_log(log_importance_t verbosity, const char *format, ...) ATTRIB_PRINTF(2, 3);
|
|
|
|
|
void _sway_vlog(log_importance_t verbosity, const char *format, va_list args) ATTRIB_PRINTF(2, 0);
|
|
|
|
|
const char *sway_strip_path(const char *filepath);
|
|
|
|
|
|
|
|
|
|
#define sway_log(verb, fmt, ...) \
|
|
|
|
|
_sway_log(verb, "[%s:%d] " fmt, sway_strip_path(__FILE__), __LINE__, ##__VA_ARGS__)
|
|
|
|
|
|
|
|
|
|
#define sway_vlog(verb, fmt, args) \
|
|
|
|
|
_sway_vlog(verb, "[%s:%d] " fmt, sway_strip_path(__FILE__), __LINE__, args)
|
|
|
|
|
|
|
|
|
|
#define sway_log_errno(verb, fmt, ...) \
|
|
|
|
|
sway_log(verb, fmt ": %s", ##__VA_ARGS__, strerror(errno))
|
|
|
|
|
|
2015-08-08 17:01:22 -04:00
|
|
|
#endif
|