diff --git a/include/common/log.h b/include/common/log.h index b2ae2efd..e3beb8cb 100644 --- a/include/common/log.h +++ b/include/common/log.h @@ -11,4 +11,9 @@ void info(const char *msg, ...); */ void warn(const char *err, ...); +/** + * die - print fatal message and exit() + */ +void die(const char *err, ...); + #endif /* __LABWC_LOG_H */ diff --git a/src/common/log.c b/src/common/log.c index 566c0d7b..b9986fb7 100644 --- a/src/common/log.c +++ b/src/common/log.c @@ -32,3 +32,15 @@ warn(const char *err, ...) fprintf(stderr, LABWC_COLOR_RESET); fprintf(stderr, "\n"); } + +void +die(const char *err, ...) +{ + va_list params; + fprintf(stderr, "[labwc] fatal: "); + va_start(params, err); + vfprintf(stderr, err, params); + va_end(params); + fprintf(stderr, "\n"); + exit(EXIT_FAILURE); +}