diff options
Diffstat (limited to 'include')
-rw-r--r-- | include/log.h | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/include/log.h b/include/log.h index adf431ab..41399a9f 100644 --- a/include/log.h +++ b/include/log.h @@ -33,22 +33,26 @@ void _sway_vlog(sway_log_importance_t verbosity, const char *format, va_list arg void _sway_abort(const char *filename, ...) ATTRIB_PRINTF(1, 2); bool _sway_assert(bool condition, const char* format, ...) ATTRIB_PRINTF(2, 3); -// TODO: get meson to precompute this, for better reproducibility/less overhead -const char *_sway_strip_path(const char *filepath); +#ifdef SWAY_REL_SRC_DIR +// strip prefix from __FILE__, leaving the path relative to the project root +#define _SWAY_FILENAME ((const char *)__FILE__ + sizeof(SWAY_REL_SRC_DIR) - 1) +#else +#define _SWAY_FILENAME __FILE__ +#endif #define sway_log(verb, fmt, ...) \ - _sway_log(verb, "[%s:%d] " fmt, _sway_strip_path(__FILE__), __LINE__, ##__VA_ARGS__) + _sway_log(verb, "[%s:%d] " fmt, _SWAY_FILENAME, __LINE__, ##__VA_ARGS__) #define sway_vlog(verb, fmt, args) \ - _sway_vlog(verb, "[%s:%d] " fmt, _sway_strip_path(__FILE__), __LINE__, args) + _sway_vlog(verb, "[%s:%d] " fmt, _SWAY_FILENAME, __LINE__, args) #define sway_log_errno(verb, fmt, ...) \ sway_log(verb, fmt ": %s", ##__VA_ARGS__, strerror(errno)) #define sway_abort(FMT, ...) \ - _sway_abort("[%s:%d] " FMT, _sway_strip_path(__FILE__), __LINE__, ##__VA_ARGS__) + _sway_abort("[%s:%d] " FMT, _SWAY_FILENAME, __LINE__, ##__VA_ARGS__) #define sway_assert(COND, FMT, ...) \ - _sway_assert(COND, "[%s:%d] %s:" FMT, _sway_strip_path(__FILE__), __LINE__, __PRETTY_FUNCTION__, ##__VA_ARGS__) + _sway_assert(COND, "[%s:%d] %s:" FMT, _SWAY_FILENAME, __LINE__, __PRETTY_FUNCTION__, ##__VA_ARGS__) #endif |