From 093ec8103f8de58d890a77b458985ecf4293bfa7 Mon Sep 17 00:00:00 2001 Message-Id: <093ec8103f8de58d890a77b458985ecf4293bfa7.1715547923.git.mdw@distorted.org.uk> From: Mark Wooding Date: Sat, 21 Feb 2009 20:43:33 +0000 Subject: [PATCH] Remove fossils There's only been one log implementation exported to plugins for ages. As well as rationalizing the code in this light we make the disorder_ names the canonical ones and provide macros to make all the existing code work. I don't see any need to convert code to use the canonical names currently. Organization: Straylight/Edgeware From: Richard Kettlewell --- lib/Makefile.am | 4 ++-- lib/log-impl.h | 58 ------------------------------------------------- lib/log.c | 38 +++++++++++++++++++++++++++----- lib/log.h | 20 +++++++++++++---- server/api.c | 3 --- 5 files changed, 50 insertions(+), 73 deletions(-) delete mode 100644 lib/log-impl.h diff --git a/lib/Makefile.am b/lib/Makefile.am index f7d99ac..af4f8a6 100644 --- a/lib/Makefile.am +++ b/lib/Makefile.am @@ -54,10 +54,10 @@ libdisorder_a_SOURCES=charset.c charset.h \ ifreq.c ifreq.h \ inputline.c inputline.h \ kvp.c kvp.h \ - log.c log.h log-impl.h \ + log.c log.h \ logfd.c logfd.h \ macros.c macros-builtin.c macros.h \ - mem.c mem.h mem-impl.h \ + mem.c mem.h \ mime.h mime.c \ mixer.c mixer.h mixer-oss.c mixer-alsa.c \ printf.c printf.h \ diff --git a/lib/log-impl.h b/lib/log-impl.h deleted file mode 100644 index de47cf2..0000000 --- a/lib/log-impl.h +++ /dev/null @@ -1,58 +0,0 @@ -/* - * This file is part of DisOrder. - * Copyright (C) 2004, 2005, 2007, 2008 Richard Kettlewell - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -/** @file lib/log-impl.h @brief Errors and logging */ - -/** @brief Log an error and quit - * - * If @c ${DISORDER_FATAL_ABORT} is defined (as anything) then the process - * is aborted, so you can get a backtrace. - */ -void disorder_fatal(int errno_value, const char *msg, ...) { - va_list ap; - - va_start(ap, msg); - elog(LOG_CRIT, errno_value, msg, ap); - va_end(ap); - if(getenv("DISORDER_FATAL_ABORT")) abort(); - exitfn(EXIT_FAILURE); -} - -/** @brief Log an error */ -void disorder_error(int errno_value, const char *msg, ...) { - va_list ap; - - va_start(ap, msg); - elog(LOG_ERR, errno_value, msg, ap); - va_end(ap); -} - -/** @brief Log an informational message */ -void disorder_info(const char *msg, ...) { - va_list ap; - - va_start(ap, msg); - elog(LOG_INFO, 0, msg, ap); - va_end(ap); -} - -/* -Local Variables: -c-basic-offset:2 -comment-column:40 -End: -*/ diff --git a/lib/log.c b/lib/log.c index f885e88..3f57073 100644 --- a/lib/log.c +++ b/lib/log.c @@ -194,15 +194,41 @@ void elog(int pri, int errno_value, const char *fmt, va_list ap) { } } -#define disorder_fatal fatal -#define disorder_error error -#define disorder_info info +/** @brief Log an error and quit + * + * If @c ${DISORDER_FATAL_ABORT} is defined (as anything) then the process + * is aborted, so you can get a backtrace. + */ +void disorder_fatal(int errno_value, const char *msg, ...) { + va_list ap; + + va_start(ap, msg); + elog(LOG_CRIT, errno_value, msg, ap); + va_end(ap); + if(getenv("DISORDER_FATAL_ABORT")) abort(); + exitfn(EXIT_FAILURE); +} + +/** @brief Log an error */ +void disorder_error(int errno_value, const char *msg, ...) { + va_list ap; -/* shared implementation of vararg functions */ -#include "log-impl.h" + va_start(ap, msg); + elog(LOG_ERR, errno_value, msg, ap); + va_end(ap); +} + +/** @brief Log an informational message */ +void disorder_info(const char *msg, ...) { + va_list ap; + + va_start(ap, msg); + elog(LOG_INFO, 0, msg, ap); + va_end(ap); +} /** @brief Log a debug message */ -void debug(const char *msg, ...) { +void disorder_debug(const char *msg, ...) { va_list ap; va_start(ap, msg); diff --git a/lib/log.h b/lib/log.h index e7f6e43..4d91008 100644 --- a/lib/log.h +++ b/lib/log.h @@ -30,17 +30,29 @@ void set_progname(char **argv); void elog(int pri, int errno_value, const char *fmt, va_list ap); -void fatal(int errno_value, const char *msg, ...) attribute((noreturn)) +void disorder_fatal(int errno_value, const char *msg, ...) attribute((noreturn)) attribute((format (printf, 2, 3))); -void error(int errno_value, const char *msg, ...) +void disorder_error(int errno_value, const char *msg, ...) attribute((format (printf, 2, 3))); -void info(const char *msg, ...) +void disorder_info(const char *msg, ...) attribute((format (printf, 1, 2))); -void debug(const char *msg, ...) +void disorder_debug(const char *msg, ...) attribute((format (printf, 1, 2))); /* report a message of the given class. @errno_value@ if present an * non-zero is included. @fatal@ terminates the process. */ +/** @brief Backward-compatibility alias for disorder_fatal() */ +#define fatal disorder_fatal + +/** @brief Backward-compatibility alias for disorder_error() */ +#define error disorder_error + +/** @brief Backward-compatibility alias for disorder_info() */ +#define info disorder_info + +/** @brief Backward-compatibility alias for disorder_debug() */ +#define debug disorder_debug + extern int debugging; /* set when debugging enabled */ diff --git a/server/api.c b/server/api.c index cbcdf90..e973fbe 100644 --- a/server/api.c +++ b/server/api.c @@ -22,9 +22,6 @@ */ #include "disorder-server.h" -/* shared implementation of vararg functions */ -#include "log-impl.h" - void *disorder_malloc(size_t n) { return xmalloc(n); } -- [mdw]