[MINOR] log: ability to override the syslog tag
One of the requirements we have is to run multiple instances of haproxy on a
single host; this is so that we can split the responsibilities (and change
permissions) between product teams. An issue we ran up against is how we
would distinguish between the logs generated by each instance. The solution
we came up with (please let me know if there is a better way) is to override
the application tag written to syslog. We can then configure syslog to write
these to different files.
I have attached a patch adding a global option 'log-tag' to override the
default syslog tag 'haproxy' (actually defaults to argv[0]).
diff --git a/src/log.c b/src/log.c
index d52727b..333cbc6 100644
--- a/src/log.c
+++ b/src/log.c
@@ -178,7 +178,7 @@
int nbloggers = 0;
char *log_ptr;
- if (level < 0 || progname == NULL || message == NULL)
+ if (level < 0 || message == NULL)
return;
if (unlikely(date.tv_sec != tvsec || dataptr == NULL)) {
@@ -193,7 +193,7 @@
monthname[tm.tm_mon],
tm.tm_mday, tm.tm_hour, tm.tm_min, tm.tm_sec,
global.log_send_hostname ? global.log_send_hostname : "",
- progname, pid);
+ global.log_tag, pid);
/* WARNING: depending upon implementations, snprintf may return
* either -1 or the number of bytes that would be needed to store
* the total message. In both cases, we must adjust it.