From 34320ea5a34e53ede384dd408f3484cb872337cc Mon Sep 17 00:00:00 2001 From: Matthias Schiffer Date: Tue, 28 Feb 2012 18:13:11 +0100 Subject: Add config parsing --- src/fastd.h | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) (limited to 'src/fastd.h') diff --git a/src/fastd.h b/src/fastd.h index 2d372a2..59fdf90 100644 --- a/src/fastd.h +++ b/src/fastd.h @@ -127,17 +127,19 @@ struct _fastd_context { }; -#define pr_log(context, level, args...) if ((context)->conf == NULL || (level) <= (context)->conf->loglevel) do { fprintf(stderr, args); fputs("\n", stderr); } while(0) +#define pr_log(context, level, prefix, args...) if ((context)->conf == NULL || (level) <= (context)->conf->loglevel) \ + do { fputs(prefix, stderr); fprintf(stderr, args); fputs("\n", stderr); } while(0) -#define pr_fatal(context, args...) pr_log(context, LOG_FATAL, args) -#define pr_error(context, args...) pr_log(context, LOG_ERROR, args) -#define pr_warn(context, args...) pr_log(context, LOG_WARN, args) -#define pr_info(context, args...) pr_log(context, LOG_INFO, args) -#define pr_debug(context, args...) pr_log(context, LOG_DEBUG, args) +#define pr_fatal(context, args...) pr_log(context, LOG_FATAL, "Fatal: ", args) +#define pr_error(context, args...) pr_log(context, LOG_ERROR, "Error: ", args) +#define pr_warn(context, args...) pr_log(context, LOG_WARN, "Warning: ", args) +#define pr_info(context, args...) pr_log(context, LOG_INFO, "", args) +#define pr_debug(context, args...) pr_log(context, LOG_DEBUG, "DEBUG: ", args) -#define exit_fatal(context, args...) do { pr_fatal(context, args); exit(1); } while(0) +#define exit_fatal(context, args...) do { pr_fatal(context, args); abort(); } while(0) #define exit_bug(context, message) exit_fatal(context, "BUG: %s", message) -#define exit_errno(context, message) exit_fatal(context, "%s: %s", message, strerror(errno)) +#define exit_error(context, args...) do { pr_error(context, args); exit(1); } while(0) +#define exit_errno(context, message) exit_error(context, "%s: %s", message, strerror(errno)) static inline fastd_buffer fastd_buffer_alloc(size_t len, size_t head_space) { -- cgit v1.2.3