MINOR: spoe: Add loggers dedicated to the SPOE agent
Now it is possible to configure a logger in a spoe-agent section using a "log"
line, as for a proxy. "no log", "log global" and "log <address> ..." syntaxes
are supported.
diff --git a/doc/SPOE.txt b/doc/SPOE.txt
index ce119dc..36e174e 100644
--- a/doc/SPOE.txt
+++ b/doc/SPOE.txt
@@ -165,6 +165,7 @@
following keywords are supported :
- groups
+ - log
- maxconnrate
- maxerrrate
- max-frame-size
@@ -196,6 +197,16 @@
See also: "spoe-group" section.
+log global
+log <address> [len <length>] [format <format>] <facility> [<level> [<minlevel>]]
+no log
+ Enable per-instance logging of events and traffic.
+
+ Prefix :
+ no should be used when the logger list must be flushed.
+
+ See the HAProxy Configuration Manual for details about this option.
+
maxconnrate <number>
Set the maximum number of connections per second to <number>. The SPOE will
stop to open new connections if the maximum is reached and will wait to
diff --git a/include/types/spoe.h b/include/types/spoe.h
index 9354b55..b7d54f3 100644
--- a/include/types/spoe.h
+++ b/include/types/spoe.h
@@ -30,6 +30,7 @@
#include <types/filters.h>
#include <types/freq_ctr.h>
+#include <types/log.h>
#include <types/proxy.h>
#include <types/sample.h>
#include <types/stream.h>
diff --git a/src/flt_spoe.c b/src/flt_spoe.c
index 760e26c..0706634 100644
--- a/src/flt_spoe.c
+++ b/src/flt_spoe.c
@@ -91,6 +91,9 @@
struct list curgphs;
struct list curvars;
+/* list of log servers used during the parsing */
+struct list curlogsrvs;
+
/* Pools used to allocate SPOE structs */
static struct pool_head *pool_head_spoe_ctx = NULL;
static struct pool_head *pool_head_spoe_appctx = NULL;
@@ -2930,11 +2933,9 @@
{
struct spoe_config *conf = fconf->conf;
- memset(&conf->agent_fe, 0, sizeof(conf->agent_fe));
- init_new_proxy(&conf->agent_fe);
- conf->agent_fe.parent = conf->agent;
+ /* conf->agent_fe was already initialized during the config
+ * parsing. Finish initialization. */
conf->agent_fe.last_change = now.tv_sec;
- conf->agent_fe.id = conf->agent->id;
conf->agent_fe.cap = PR_CAP_FE;
conf->agent_fe.mode = PR_MODE_TCP;
conf->agent_fe.maxconn = 0;
@@ -3666,6 +3667,15 @@
cur_arg++;
}
}
+ else if (!strcmp(args[0], "log")) {
+ char *errmsg = NULL;
+
+ if (!parse_logsrv(args, &curlogsrvs, (kwm == 1), &errmsg)) {
+ ha_alert("parsing [%s:%d] : %s : %s\n", file, linenum, args[0], errmsg);
+ err_code |= ERR_ALERT | ERR_FATAL;
+ goto out;
+ }
+ }
else if (*args[0]) {
ha_alert("parsing [%s:%d] : unknown keyword '%s' in spoe-agent section.\n",
file, linenum, args[0]);
@@ -3963,6 +3973,7 @@
struct spoe_group *grp, *grpback;
struct spoe_placeholder *ph, *phback;
struct spoe_var_placeholder *vph, *vphback;
+ struct logsrv *logsrv, *logsrvback;
char *file = NULL, *engine = NULL;
int ret, pos = *cur_arg + 1;
@@ -3971,6 +3982,7 @@
LIST_INIT(&curmphs);
LIST_INIT(&curgphs);
LIST_INIT(&curvars);
+ LIST_INIT(&curlogsrvs);
conf = calloc(1, sizeof(*conf));
if (conf == NULL) {
@@ -4287,6 +4299,19 @@
conf->id = strdup(engine ? engine : curagent->id);
conf->agent = curagent;
+
+ /* Start agent's proxy initialization here. It will be finished during
+ * the filter init. */
+ memset(&conf->agent_fe, 0, sizeof(conf->agent_fe));
+ init_new_proxy(&conf->agent_fe);
+ conf->agent_fe.id = conf->agent->id;
+ conf->agent_fe.parent = conf->agent;
+
+ list_for_each_entry_safe(logsrv, logsrvback, &curlogsrvs, list) {
+ LIST_DEL(&logsrv->list);
+ LIST_ADDQ(&conf->agent_fe.logsrvs, &logsrv->list);
+ }
+
list_for_each_entry_safe(ph, phback, &curmphs, list) {
LIST_DEL(&ph->list);
spoe_release_placeholder(ph);
@@ -4347,6 +4372,10 @@
LIST_DEL(&msg->list);
spoe_release_message(msg);
}
+ list_for_each_entry_safe(logsrv, logsrvback, &curlogsrvs, list) {
+ LIST_DEL(&logsrv->list);
+ free(logsrv);
+ }
free(conf);
return -1;
}