From 96cf8dffe4f7b0b910f790066ae622dc429eb522 Mon Sep 17 00:00:00 2001 From: Jannis Hoffmann Date: Tue, 9 Jul 2024 13:02:45 +0200 Subject: initial commit of version 23 --- include/logmsg.h | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 include/logmsg.h (limited to 'include/logmsg.h') diff --git a/include/logmsg.h b/include/logmsg.h new file mode 100644 index 0000000..c480c8b --- /dev/null +++ b/include/logmsg.h @@ -0,0 +1,31 @@ +#ifndef LOGMSG_H +#define LOGMSG_H + +#include +#include +#include "error.h" + +extern void logmsg(const char *who, int ecode, unsigned int class, + const char *msg); + +/* useful combinations of params */ +/* class: FATAL (hard) - system error */ +#define err_sys(w,e) logmsg(w,e,FATAL,"") +#define err_sys_plus(w,e,m) logmsg(w,e,FATAL,m) +/* class: WARN (application) - temporary error */ +#define err_tmp(w,e,m) logmsg(w,e,WARN,m) +#define err_tmp_plus(w,e,m) logmsg(w,e,WARN,m) +/* class: facultative ('int'ernal definition */ +#define err_int(w,e,c) logmsg(w,e,c,"") +#define err_int_plus(w,e,c,m) logmsg(w,e,c,m) +/* log messages */ +/* #define log(w,m) logmsg(w,0,LOG,m) // obsoleted by */ +#define log_who(w,m) logmsg(w,0,LOG,m) +#define log_anon(m) logmsg("",0,LOG,m) +#define log_cat(n) logmsg("",0,CAT,m) + +/* build log message from multiple partial strings */ +extern char *build_log_msg(const char *[]); +#define B(...) build_log_msg((const char *[]){__VA_ARGS__,NULL}) // K/R sect. 7.3 + +#endif -- cgit v1.2.3