MEDIUM: logs: add a new RFC5424 log-format for the structured-data
This patch adds a new RFC5424-specific log-format for the structured-data
that is automatically send by __send_log() when the sender is in RFC5424
mode.
A new statement "log-format-sd" should be used in order to set log-format
for the structured-data part in RFC5424 formatted syslog messages.
Example:
log-format-sd [exampleSDID@1234\ bytes=\"%B\"\ status=\"%ST\"]
diff --git a/include/proto/log.h b/include/proto/log.h
index fca7fdd..62b39ea 100644
--- a/include/proto/log.h
+++ b/include/proto/log.h
@@ -43,9 +43,12 @@
extern char default_host_tag_pid_log_format[];
extern char rfc5424_host_tag_pid_log_format[];
+extern char default_rfc5424_sd_log_format[];
+
extern char *logheader;
extern char *logheader_rfc5424;
extern char *logline;
+extern char *logline_rfc5424;
int build_logline(struct stream *s, char *dst, size_t maxsize, struct list *list_format);
@@ -111,7 +114,7 @@
* It doesn't care about errors nor does it report them.
*/
-void __send_log(struct proxy *p, int level, char *message, size_t size);
+void __send_log(struct proxy *p, int level, char *message, size_t size, char *sd, size_t sd_size);
/*
* returns log format for <fmt> or -1 if not found.
diff --git a/include/types/arg.h b/include/types/arg.h
index fd35354..5430de7 100644
--- a/include/types/arg.h
+++ b/include/types/arg.h
@@ -69,6 +69,7 @@
ARGC_STK, /* sticking rule */
ARGC_TRK, /* tracking rule */
ARGC_LOG, /* log-format */
+ ARGC_LOGSD, /* log-format-sd */
ARGC_HRQ, /* http-request */
ARGC_HRS, /* http-response */
ARGC_UIF, /* unique-id-format */
diff --git a/include/types/log.h b/include/types/log.h
index 2cfd31a..6a68b5d 100644
--- a/include/types/log.h
+++ b/include/types/log.h
@@ -30,7 +30,7 @@
#define NB_LOG_FACILITIES 24
#define NB_LOG_LEVELS 8
-#define NB_MSG_IOVEC_ELEMENTS 3
+#define NB_MSG_IOVEC_ELEMENTS 4
#define SYSLOG_PORT 514
#define UNIQUEID_LEN 128
diff --git a/include/types/proxy.h b/include/types/proxy.h
index 9793a29..49debc6 100644
--- a/include/types/proxy.h
+++ b/include/types/proxy.h
@@ -345,6 +345,7 @@
unsigned int log_count; /* number of logs produced by the frontend */
struct list logsrvs;
struct list logformat; /* log_format linked list */
+ struct list logformat_sd; /* log_format linked list for the RFC5424 structured-data part */
char *log_tag; /* override default syslog tag */
struct chunk log_htp; /* a syslog header part that contains hostname, log_tag and pid (RFC3164 format) */
struct chunk log_htp_rfc5424; /* a syslog header part that contains hostname, log_tag and pid (RFC5424 format) */
@@ -404,6 +405,9 @@
int uif_line; /* file name where the unique-id-format string appears */
char *uif_file; /* file name where the unique-id-format string appears (strdup) */
char *uniqueid_format_string; /* unique-id format string */
+ char *logformat_sd_string; /* log format string for the RFC5424 structured-data part */
+ char *lfsd_file; /* file name where the structured-data logformat string for RFC5424 appears (strdup) */
+ int lfsd_line; /* file name where the structured-data logformat string for RFC5424 appears */
} conf; /* config information */
void *parent; /* parent of the proxy when applicable */
struct comp *comp; /* http compression */