mirror of
https://github.com/labwc/labwc.git
synced 2025-11-04 13:30:07 -05:00
log: add die() for convenience
This commit is contained in:
parent
c8040e4d3b
commit
aab7b71520
2 changed files with 17 additions and 0 deletions
|
|
@ -11,4 +11,9 @@ void info(const char *msg, ...);
|
||||||
*/
|
*/
|
||||||
void warn(const char *err, ...);
|
void warn(const char *err, ...);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* die - print fatal message and exit()
|
||||||
|
*/
|
||||||
|
void die(const char *err, ...);
|
||||||
|
|
||||||
#endif /* __LABWC_LOG_H */
|
#endif /* __LABWC_LOG_H */
|
||||||
|
|
|
||||||
|
|
@ -32,3 +32,15 @@ warn(const char *err, ...)
|
||||||
fprintf(stderr, LABWC_COLOR_RESET);
|
fprintf(stderr, LABWC_COLOR_RESET);
|
||||||
fprintf(stderr, "\n");
|
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);
|
||||||
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue