REORG: include: move the error reporting functions to from log.h to errors.h

Most of the files dealing with error reports have to include log.h in order
to access ha_alert(), ha_warning() etc. But while these functions don't
depend on anything, log.h depends on a lot of stuff because it deals with
log-formats and samples. As a result it's impossible not to embark long
dependencies when using ha_warning() or qfprintf().

This patch moves these low-level functions to errors.h, which already
defines the error codes used at the same places. About half of the users
of log.h could be adjusted, sometimes revealing other issues such as
missing tools.h. Interestingly the total preprocessed size shrunk by
4%.
This commit is contained in:
Willy Tarreau 2020-06-05 17:27:29 +02:00
parent 251c2aae06
commit 36979d9ad5
46 changed files with 79 additions and 54 deletions

View File

@ -17,9 +17,9 @@
#include <stdarg.h>
#include <haproxy/arg.h>
#include <haproxy/errors.h>
#include <haproxy/global.h>
#include <haproxy/hlua.h>
#include <haproxy/log.h>
#include <haproxy/spoe.h>
#include <haproxy/stream-t.h>
#include <haproxy/time.h>

View File

@ -23,9 +23,10 @@
#include <haproxy/http.h>
#include <haproxy/http_htx.h>
#include <haproxy/htx.h>
#include <haproxy/listener.h>
#include <haproxy/pool.h>
#include <haproxy/list.h>
#include <haproxy/listener.h>
#include <haproxy/log.h>
#include <haproxy/pool.h>
#include <haproxy/compression.h>
#include <haproxy/pipe.h>

View File

@ -23,8 +23,8 @@
#define _HAPROXY_CFGPARSE_H
#include <haproxy/api.h>
#include <haproxy/errors.h>
#include <haproxy/list-t.h>
#include <haproxy/log.h>
#include <haproxy/proxy.h>
/* configuration sections */

View File

@ -22,6 +22,8 @@
#ifndef _HAPROXY_ERRORS_H
#define _HAPROXY_ERRORS_H
#include <stdio.h>
/* These flags may be used in various functions which are called from within
* loops (eg: to start all listeners from all proxies). They provide enough
* information to let the caller decide what to do. ERR_WARN and ERR_ALERT
@ -56,6 +58,34 @@ enum {
PE_ARG_NOT_FOUND, /* argument references something not found */
};
/************ Error reporting functions from log.c ***********/
/*
* Displays the message on stderr with the date and pid. Overrides the quiet
* mode during startup.
*/
void ha_alert(const char *fmt, ...)
__attribute__ ((format(printf, 1, 2)));
/*
* Displays the message on stderr with the date and pid.
*/
void ha_warning(const char *fmt, ...)
__attribute__ ((format(printf, 1, 2)));
/*
* Displays the message on stderr with the date and pid.
*/
void ha_notice(const char *fmt, ...)
__attribute__ ((format(printf, 1, 2)));
/*
* Displays the message on <out> only if quiet mode is not set.
*/
void qfprintf(FILE *out, const char *fmt, ...)
__attribute__ ((format(printf, 2, 3)));
#endif /* _HAPROXY_ERRORS_H */
/*

View File

@ -83,31 +83,6 @@ int parse_logformat_string(const char *str, struct proxy *curproxy, struct list
/* Parse "log" keyword and update the linked list. */
int parse_logsrv(char **args, struct list *logsrvs, int do_del, char **err);
/*
* Displays the message on stderr with the date and pid. Overrides the quiet
* mode during startup.
*/
void ha_alert(const char *fmt, ...)
__attribute__ ((format(printf, 1, 2)));
/*
* Displays the message on stderr with the date and pid.
*/
void ha_warning(const char *fmt, ...)
__attribute__ ((format(printf, 1, 2)));
/*
* Displays the message on stderr with the date and pid.
*/
void ha_notice(const char *fmt, ...)
__attribute__ ((format(printf, 1, 2)));
/*
* Displays the message on <out> only if quiet mode is not set.
*/
void qfprintf(FILE *out, const char *fmt, ...)
__attribute__ ((format(printf, 2, 3)));
/*
* This function adds a header to the message and sends the syslog message
* using a printf format string

View File

@ -8,11 +8,11 @@
#include <haproxy/http_ana.h>
#include <haproxy/http_fetch.h>
#include <haproxy/http_htx.h>
#include <haproxy/log.h>
#include <haproxy/thread.h>
#include <haproxy/global.h>
#include <haproxy/arg.h>
#include <haproxy/sample.h>
#include <haproxy/tools.h>
#include <import/xxhash.h>
#include <import/lru.h>
#include <51Degrees.h>

View File

@ -17,8 +17,8 @@
#include <haproxy/acl.h>
#include <haproxy/auth.h>
#include <haproxy/api.h>
#include <haproxy/errors.h>
#include <haproxy/list.h>
#include <haproxy/log.h>
#include <haproxy/pattern.h>
#include <haproxy/proxy-t.h>
#include <haproxy/tools.h>

View File

@ -12,10 +12,10 @@
#include <haproxy/action.h>
#include <haproxy/api.h>
#include <haproxy/errors.h>
#include <haproxy/obj_type.h>
#include <haproxy/pool.h>
#include <haproxy/list.h>
#include <haproxy/log.h>
#include <haproxy/proxy.h>
#include <haproxy/task.h>
#include <haproxy/tools.h>

View File

@ -29,8 +29,8 @@
#include <haproxy/api.h>
#include <haproxy/global.h>
#include <haproxy/errors.h>
#include <haproxy/log.h>
#include <haproxy/pattern-t.h>
#include <haproxy/sample-t.h>
#include <haproxy/thread.h>
struct userlist *userlist = NULL; /* list of all existing userlists */

View File

@ -15,11 +15,11 @@
#include <haproxy/cfgparse.h>
#include <haproxy/channel.h>
#include <haproxy/cli.h>
#include <haproxy/errors.h>
#include <haproxy/filters.h>
#include <haproxy/http_ana.h>
#include <haproxy/http_htx.h>
#include <haproxy/http_rules.h>
#include <haproxy/log.h>
#include <haproxy/proxy.h>
#include <haproxy/shctx.h>
#include <haproxy/stream.h>

View File

@ -14,6 +14,8 @@
#include <haproxy/cfgparse.h>
#include <haproxy/compression.h>
#include <haproxy/global.h>
#include <haproxy/log.h>
#include <haproxy/tools.h>
/*
* parse a line in a <global> section. Returns the error code, 0 if OK, or

View File

@ -23,6 +23,7 @@
#include <haproxy/http_htx.h>
#include <haproxy/http_rules.h>
#include <haproxy/listener.h>
#include <haproxy/log.h>
#include <haproxy/peers.h>
#include <haproxy/proxy.h>
#include <haproxy/sample.h>

View File

@ -33,6 +33,7 @@
#include <haproxy/check.h>
#include <haproxy/cli.h>
#include <haproxy/dns-t.h>
#include <haproxy/errors.h>
#include <haproxy/frontend.h>
#include <haproxy/list.h>
#include <haproxy/listener.h>

View File

@ -16,6 +16,7 @@
#include <haproxy/cfgparse.h>
#include <haproxy/connection.h>
#include <haproxy/frontend.h>
#include <haproxy/log-t.h>
#include <haproxy/namespace.h>
#include <haproxy/hash.h>
#include <haproxy/net_helper.h>

View File

@ -8,10 +8,10 @@
#include <haproxy/http_fetch.h>
#include <haproxy/http_htx.h>
#include <haproxy/htx.h>
#include <haproxy/log.h>
#include <haproxy/global.h>
#include <haproxy/arg.h>
#include <haproxy/sample.h>
#include <haproxy/tools.h>
#include <dac.h>
static struct {

View File

@ -30,9 +30,9 @@
#include <haproxy/api.h>
#include <haproxy/cfgparse.h>
#include <haproxy/check.h>
#include <haproxy/errors.h>
#include <haproxy/global.h>
#include <haproxy/list.h>
#include <haproxy/log.h>
#include <haproxy/proxy.h>
#include <haproxy/server.h>
#include <haproxy/signal.h>

View File

@ -14,12 +14,12 @@
#include <haproxy/api.h>
#include <haproxy/channel-t.h>
#include <haproxy/errors.h>
#include <haproxy/filters.h>
#include <haproxy/global.h>
#include <haproxy/http_ana-t.h>
#include <haproxy/http_htx.h>
#include <haproxy/htx.h>
#include <haproxy/log.h>
#include <haproxy/proxy-t.h>
#include <haproxy/stream.h>
#include <haproxy/tools.h>

View File

@ -17,6 +17,7 @@
#include <haproxy/h1_htx.h>
#include <haproxy/http.h>
#include <haproxy/htx.h>
#include <haproxy/tools.h>
/* Estimate the size of the HTX headers after the parsing, including the EOH. */
static size_t h1_eval_htx_hdrs_size(const struct http_hdr *hdrs)

View File

@ -40,6 +40,7 @@
#include <haproxy/http_ana.h>
#include <haproxy/http_fetch.h>
#include <haproxy/http_rules.h>
#include <haproxy/log.h>
#include <haproxy/map.h>
#include <haproxy/obj_type.h>
#include <haproxy/pattern.h>

View File

@ -19,9 +19,9 @@
#include <lualib.h>
#include <haproxy/cli-t.h>
#include <haproxy/errors.h>
#include <haproxy/hlua-t.h>
#include <haproxy/http.h>
#include <haproxy/log.h>
#include <haproxy/net_helper.h>
#include <haproxy/pattern-t.h>
#include <haproxy/proxy.h>

View File

@ -26,6 +26,7 @@
#include <haproxy/http_ana.h>
#include <haproxy/http_htx.h>
#include <haproxy/http_rules.h>
#include <haproxy/log.h>
#include <haproxy/pattern.h>
#include <haproxy/pool.h>
#include <haproxy/regex.h>

View File

@ -19,6 +19,7 @@
#include <haproxy/channel.h>
#include <haproxy/check.h>
#include <haproxy/connection.h>
#include <haproxy/errors.h>
#include <haproxy/filters.h>
#include <haproxy/http.h>
#include <haproxy/http_ana.h>

View File

@ -17,6 +17,7 @@
#include <haproxy/api.h>
#include <haproxy/global.h>
#include <haproxy/http_fetch.h>
#include <haproxy/log.h>
#include <haproxy/regex.h>
#include <haproxy/sample.h>

View File

@ -24,6 +24,7 @@
#include <haproxy/global.h>
#include <haproxy/http.h>
#include <haproxy/http_rules.h>
#include <haproxy/log.h>
#include <haproxy/pool.h>
#include <haproxy/tools.h>
#include <haproxy/version.h>

View File

@ -16,13 +16,13 @@
#include <haproxy/action-t.h>
#include <haproxy/api.h>
#include <haproxy/check.h>
#include <haproxy/errors.h>
#include <haproxy/list.h>
#include <haproxy/mailers.h>
#include <haproxy/pool.h>
#include <haproxy/tools.h>
#include <haproxy/time.h>
#include <haproxy/thread.h>
#include <haproxy/log.h>
#include <haproxy/proxy-t.h>
#include <haproxy/server-t.h>
#include <haproxy/task.h>

View File

@ -13,6 +13,7 @@
#include <haproxy/api.h>
#include <haproxy/cfgparse.h>
#include <haproxy/connection.h>
#include <haproxy/errors.h>
#include <haproxy/fcgi.h>
#include <haproxy/fcgi-app.h>
#include <haproxy/h1.h>

View File

@ -22,6 +22,7 @@
#include <haproxy/hpack-tbl.h>
#include <haproxy/http_htx.h>
#include <haproxy/htx.h>
#include <haproxy/log.h>
#include <haproxy/net_helper.h>
#include <haproxy/session-t.h>
#include <haproxy/stream.h>

View File

@ -24,7 +24,6 @@
#include <haproxy/cfgparse.h>
#include <haproxy/errors.h>
#include <haproxy/global.h>
#include <haproxy/log.h>
#include <haproxy/mworker.h>
#include <haproxy/task.h>

View File

@ -20,11 +20,11 @@
#include <haproxy/api.h>
#include <haproxy/cfgparse.h>
#include <haproxy/cli.h>
#include <haproxy/errors.h>
#include <haproxy/fd.h>
#include <haproxy/global.h>
#include <haproxy/list.h>
#include <haproxy/listener.h>
#include <haproxy/log.h>
#include <haproxy/mworker.h>
#include <haproxy/peers.h>
#include <haproxy/proxy-t.h>

View File

@ -11,10 +11,10 @@
#include <string.h>
#include <haproxy/api.h>
#include <haproxy/chunk.h>
#include <haproxy/errors.h>
#include <haproxy/global.h>
#include <haproxy/hash.h>
#include <haproxy/log.h>
#include <haproxy/namespace.h>
#include <haproxy/signal.h>

View File

@ -25,9 +25,9 @@
#include <haproxy/channel.h>
#include <haproxy/cli.h>
#include <haproxy/dict.h>
#include <haproxy/errors.h>
#include <haproxy/fd.h>
#include <haproxy/frontend.h>
#include <haproxy/log.h>
#include <haproxy/net_helper.h>
#include <haproxy/obj_type-t.h>
#include <haproxy/peers.h>

View File

@ -16,12 +16,12 @@
#include <haproxy/cfgparse.h>
#include <haproxy/channel.h>
#include <haproxy/cli.h>
#include <haproxy/errors.h>
#include <haproxy/global.h>
#include <haproxy/thread.h>
#include <haproxy/pool.h>
#include <haproxy/list.h>
#include <haproxy/log.h>
#include <haproxy/stats-t.h>
#include <haproxy/stream_interface.h>
#include <haproxy/tools.h>

View File

@ -32,7 +32,6 @@
#include <haproxy/global.h>
#include <haproxy/list.h>
#include <haproxy/listener.h>
#include <haproxy/log.h>
#include <haproxy/tools.h>
#include <haproxy/time.h>
#include <haproxy/version.h>

View File

@ -25,8 +25,8 @@
#include <haproxy/api.h>
#include <haproxy/buf.h>
#include <haproxy/connection.h>
#include <haproxy/errors.h>
#include <haproxy/global.h>
#include <haproxy/log.h>
#include <haproxy/stream_interface.h>
#include <haproxy/tools.h>
#include <haproxy/ticks.h>

View File

@ -15,8 +15,8 @@
#include <string.h>
#include <haproxy/api.h>
#include <haproxy/errors.h>
#include <haproxy/global.h>
#include <haproxy/log.h>
#include <haproxy/regex.h>
#include <haproxy/tools.h>

View File

@ -21,10 +21,10 @@
#include <haproxy/auth.h>
#include <haproxy/buf.h>
#include <haproxy/chunk.h>
#include <haproxy/errors.h>
#include <haproxy/global.h>
#include <haproxy/hash.h>
#include <haproxy/http.h>
#include <haproxy/log.h>
#include <haproxy/net_helper.h>
#include <haproxy/protobuf.h>
#include <haproxy/proxy.h>

View File

@ -27,6 +27,7 @@
#include <haproxy/dns.h>
#include <haproxy/errors.h>
#include <haproxy/global.h>
#include <haproxy/log.h>
#include <haproxy/mailers.h>
#include <haproxy/namespace.h>
#include <haproxy/queue.h>

View File

@ -13,9 +13,9 @@
#include <signal.h>
#include <string.h>
#include <haproxy/log.h>
#include <haproxy/task.h>
#include <haproxy/errors.h>
#include <haproxy/signal.h>
#include <haproxy/task.h>
/* Principle : we keep an in-order list of the first occurrence of all received
* signals. All occurrences of a same signal are grouped though. The signal

View File

@ -18,10 +18,11 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include <import/ist.h>
#include <haproxy/api.h>
#include <haproxy/cfgparse.h>
#include <haproxy/cli.h>
#include <import/ist.h>
#include <haproxy/errors.h>
#include <haproxy/list.h>
#include <haproxy/log.h>
#include <haproxy/time.h>

View File

@ -34,6 +34,7 @@
#include <haproxy/compression.h>
#include <haproxy/debug.h>
#include <haproxy/dns.h>
#include <haproxy/errors.h>
#include <haproxy/frontend.h>
#include <haproxy/global.h>
#include <haproxy/http.h>
@ -41,8 +42,8 @@
#include <haproxy/htx.h>
#include <haproxy/pool.h>
#include <haproxy/list.h>
#include <haproxy/listener.h>
#include <haproxy/log.h>
#include <haproxy/listener.h>
#include <haproxy/map-t.h>
#include <haproxy/pattern-t.h>
#include <haproxy/proxy.h>

View File

@ -17,6 +17,7 @@
#include <haproxy/api.h>
#include <haproxy/cfgparse.h>
#include <haproxy/cli.h>
#include <haproxy/errors.h>
#include <haproxy/global.h>
#include <haproxy/http_rules.h>
#include <haproxy/pool.h>

View File

@ -39,6 +39,7 @@
#include <haproxy/check.h>
#include <haproxy/chunk.h>
#include <haproxy/connection.h>
#include <haproxy/errors.h>
#include <haproxy/global.h>
#include <haproxy/h1.h>
#include <haproxy/http.h>

View File

@ -22,6 +22,7 @@
#include <haproxy/api.h>
#include <haproxy/buf.h>
#include <haproxy/cli.h>
#include <haproxy/errors.h>
#include <haproxy/istbuf.h>
#include <haproxy/list.h>
#include <haproxy/log.h>

View File

@ -15,7 +15,8 @@
#include <haproxy/api.h>
#include <haproxy/base64.h>
#include <haproxy/log.h>
#include <haproxy/errors.h>
#include <haproxy/list.h>
#include <haproxy/stats-t.h>
#include <haproxy/uri_auth.h>

View File

@ -8,6 +8,7 @@
#include <haproxy/http.h>
#include <haproxy/http_rules.h>
#include <haproxy/list.h>
#include <haproxy/log.h>
#include <haproxy/sample.h>
#include <haproxy/stream-t.h>
#include <haproxy/tcpcheck.h>

View File

@ -14,8 +14,8 @@
#include <haproxy/api.h>
#include <haproxy/debug.h>
#include <haproxy/errors.h>
#include <haproxy/global.h>
#include <haproxy/log.h>
#include <haproxy/thread.h>
#include <haproxy/tools.h>