summaryrefslogtreecommitdiff
path: root/include/logmsg.h
blob: c480c8bc0baa283e77e7e4ce1276ef0dc883baa9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#ifndef LOGMSG_H
#define LOGMSG_H

#include <errno.h>
#include <stdlib.h>
#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