intermediate syslog server or for simply customizing the hostname printed in
the logs.
+log-tag <string>
+ Sets the tag field in the syslog header to this string. It defaults to the
+ program name as launched from the command line, which usually is "haproxy".
+ Sometimes it can be useful to differentiate between multiple processes
+ running on the same host.
+
nbproc <number>
Creates <number> processes when going daemon. This requires the "daemon"
mode. By default, only one process is created, which is the recommended mode
char *chroot;
char *pidfile;
char *node, *desc; /* node name & description */
+ char *log_tag; /* name for syslog */
int logfac1, logfac2;
int loglev1, loglev2;
int minlvl1, minlvl2;
};
extern struct global global;
-extern char *progname; /* program name */
extern int pid; /* current process id */
extern int relative_pid; /* process id starting at 1 */
extern int actconn; /* # of active sessions */
global.log_send_hostname = malloc(len + 2);
snprintf(global.log_send_hostname, len + 2, "%s ", name);
}
+ else if (!strcmp(args[0], "log-tag")) { /* tag to report to syslog */
+ if (*(args[1]) == 0) {
+ Alert("parsing [%s:%d] : '%s' expects a tag for use in syslog.\n", file, linenum, args[0]);
+ err_code |= ERR_ALERT | ERR_FATAL;
+ goto out;
+ }
+ free(global.log_tag);
+ global.log_tag = strdup(args[1]);
+ }
else if (!strcmp(args[0], "spread-checks")) { /* random time between checks (0-50) */
if (global.spread_checks != 0) {
Alert("parsing [%s:%d]: spread-checks already specified. Continuing.\n", file, linenum);
/* list of config files */
static struct list cfg_cfgfiles = LIST_HEAD_INIT(cfg_cfgfiles);
-char *progname = NULL; /* program name */
int pid; /* current process id */
int relative_pid = 1; /* process id starting at 1 */
char *cfg_pidfile = NULL;
int err_code = 0;
struct wordlist *wl;
+ char *progname;
/* NB: POSIX does not make it mandatory for gethostname() to NULL-terminate
* the string in case of truncation, and at least FreeBSD appears not to do
while ((tmp = strchr(progname, '/')) != NULL)
progname = tmp + 1;
+ /* the process name is used for the logs only */
+ global.log_tag = strdup(progname);
+
argc--; argv++;
while (argc > 0) {
char *flag;
protocol_unbind_all();
free(global.log_send_hostname); global.log_send_hostname = NULL;
+ free(global.log_tag); global.log_tag = NULL;
free(global.chroot); global.chroot = NULL;
free(global.pidfile); global.pidfile = NULL;
free(global.node); global.node = NULL;
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)) {
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.