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%.
diff --git a/src/51d.c b/src/51d.c
index 68195cd..54e9a1e 100644
--- a/src/51d.c
+++ b/src/51d.c
@@ -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>
diff --git a/src/acl.c b/src/acl.c
index 77440ed..b1409bd 100644
--- a/src/acl.c
+++ b/src/acl.c
@@ -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>
diff --git a/src/action.c b/src/action.c
index d715379..16e96dd 100644
--- a/src/action.c
+++ b/src/action.c
@@ -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>
diff --git a/src/auth.c b/src/auth.c
index 646c010..a84e891 100644
--- a/src/auth.c
+++ b/src/auth.c
@@ -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 */
diff --git a/src/cache.c b/src/cache.c
index 56368f3..6e8d8d2 100644
--- a/src/cache.c
+++ b/src/cache.c
@@ -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>
diff --git a/src/cfgparse-global.c b/src/cfgparse-global.c
index d6d7243..a4fed04 100644
--- a/src/cfgparse-global.c
+++ b/src/cfgparse-global.c
@@ -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
diff --git a/src/cfgparse-listen.c b/src/cfgparse-listen.c
index f0c52a8..45ac8c3 100644
--- a/src/cfgparse-listen.c
+++ b/src/cfgparse-listen.c
@@ -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>
diff --git a/src/cli.c b/src/cli.c
index b6249dd..6ca0a1f 100644
--- a/src/cli.c
+++ b/src/cli.c
@@ -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>
diff --git a/src/connection.c b/src/connection.c
index e27ba74..f9741ef 100644
--- a/src/connection.c
+++ b/src/connection.c
@@ -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>
diff --git a/src/da.c b/src/da.c
index a47fc30..9b12cc5 100644
--- a/src/da.c
+++ b/src/da.c
@@ -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 {
diff --git a/src/extcheck.c b/src/extcheck.c
index 2a577b1..721e49d 100644
--- a/src/extcheck.c
+++ b/src/extcheck.c
@@ -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>
diff --git a/src/flt_trace.c b/src/flt_trace.c
index b0e448a..910f5c4 100644
--- a/src/flt_trace.c
+++ b/src/flt_trace.c
@@ -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>
diff --git a/src/h1_htx.c b/src/h1_htx.c
index e32d845..9388680 100644
--- a/src/h1_htx.c
+++ b/src/h1_htx.c
@@ -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)
diff --git a/src/hlua.c b/src/hlua.c
index fd5ba06..f2d471d 100644
--- a/src/hlua.c
+++ b/src/hlua.c
@@ -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>
diff --git a/src/hlua_fcn.c b/src/hlua_fcn.c
index cfcbcea..78b9495 100644
--- a/src/hlua_fcn.c
+++ b/src/hlua_fcn.c
@@ -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>
diff --git a/src/http_act.c b/src/http_act.c
index f83b32b..9db12de 100644
--- a/src/http_act.c
+++ b/src/http_act.c
@@ -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>
diff --git a/src/http_ana.c b/src/http_ana.c
index c4973e8..a95f079 100644
--- a/src/http_ana.c
+++ b/src/http_ana.c
@@ -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>
diff --git a/src/http_htx.c b/src/http_htx.c
index e3e21d7..8b61562 100644
--- a/src/http_htx.c
+++ b/src/http_htx.c
@@ -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>
 
diff --git a/src/http_rules.c b/src/http_rules.c
index d2bb4f2..79aa39c 100644
--- a/src/http_rules.c
+++ b/src/http_rules.c
@@ -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>
diff --git a/src/mailers.c b/src/mailers.c
index 16ee60a..94ed5b4 100644
--- a/src/mailers.c
+++ b/src/mailers.c
@@ -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>
diff --git a/src/mux_fcgi.c b/src/mux_fcgi.c
index b03210f..03e5b9c 100644
--- a/src/mux_fcgi.c
+++ b/src/mux_fcgi.c
@@ -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>
diff --git a/src/mux_h2.c b/src/mux_h2.c
index 102e74e..1a31811 100644
--- a/src/mux_h2.c
+++ b/src/mux_h2.c
@@ -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>
diff --git a/src/mworker-prog.c b/src/mworker-prog.c
index d0b9446..e77317f 100644
--- a/src/mworker-prog.c
+++ b/src/mworker-prog.c
@@ -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>
 
diff --git a/src/mworker.c b/src/mworker.c
index e2b154e..14c0e57 100644
--- a/src/mworker.c
+++ b/src/mworker.c
@@ -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>
diff --git a/src/namespace.c b/src/namespace.c
index 59d03c2..1fc8439 100644
--- a/src/namespace.c
+++ b/src/namespace.c
@@ -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>
 
diff --git a/src/peers.c b/src/peers.c
index dca5619..fa444a9 100644
--- a/src/peers.c
+++ b/src/peers.c
@@ -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>
diff --git a/src/pool.c b/src/pool.c
index 82ca79a..c185069 100644
--- a/src/pool.c
+++ b/src/pool.c
@@ -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>
diff --git a/src/proto_sockpair.c b/src/proto_sockpair.c
index c72c6ac..7d5a507 100644
--- a/src/proto_sockpair.c
+++ b/src/proto_sockpair.c
@@ -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>
diff --git a/src/raw_sock.c b/src/raw_sock.c
index 099f503..9e7f0c5 100644
--- a/src/raw_sock.c
+++ b/src/raw_sock.c
@@ -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>
diff --git a/src/regex.c b/src/regex.c
index 1c3c55f..e23e311 100644
--- a/src/regex.c
+++ b/src/regex.c
@@ -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>
 
diff --git a/src/sample.c b/src/sample.c
index f7ecb65..4ee44cf 100644
--- a/src/sample.c
+++ b/src/sample.c
@@ -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>
diff --git a/src/server.c b/src/server.c
index 3c83b63..a0fd10f 100644
--- a/src/server.c
+++ b/src/server.c
@@ -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>
diff --git a/src/signal.c b/src/signal.c
index 1f8ec83..946157e 100644
--- a/src/signal.c
+++ b/src/signal.c
@@ -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
diff --git a/src/sink.c b/src/sink.c
index 5a4980b..8128775 100644
--- a/src/sink.c
+++ b/src/sink.c
@@ -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>
diff --git a/src/stats.c b/src/stats.c
index b42ae7a..bb70884 100644
--- a/src/stats.c
+++ b/src/stats.c
@@ -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>
diff --git a/src/stick_table.c b/src/stick_table.c
index 0bdc62d..c5ddd0b 100644
--- a/src/stick_table.c
+++ b/src/stick_table.c
@@ -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>
diff --git a/src/tcpcheck.c b/src/tcpcheck.c
index ec1fede..8808a0c 100644
--- a/src/tcpcheck.c
+++ b/src/tcpcheck.c
@@ -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>
diff --git a/src/trace.c b/src/trace.c
index 997a994..b4bd90b 100644
--- a/src/trace.c
+++ b/src/trace.c
@@ -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>
diff --git a/src/uri_auth.c b/src/uri_auth.c
index 248431c..57dbadb 100644
--- a/src/uri_auth.c
+++ b/src/uri_auth.c
@@ -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>
 
diff --git a/src/vars.c b/src/vars.c
index 2e32583..9ba1720 100644
--- a/src/vars.c
+++ b/src/vars.c
@@ -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>
diff --git a/src/wdt.c b/src/wdt.c
index c17d67c3..d6a3e56 100644
--- a/src/wdt.c
+++ b/src/wdt.c
@@ -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>