MEDIUM: sink: build header in sink_write for log formats

This patch extends the sink_write prototype and code to
handle the rfc5424 and rfc3164 header.

It uses header building tools from log.c. Doing this some
functions/vars have been externalized.

facility and minlevel have been removed from the struct sink
and passed to args at sink_write because they depends of the log
and not of the sink (they remained unused by rest of the code
until now).
diff --git a/include/proto/log.h b/include/proto/log.h
index a2e9d47..6e342e3 100644
--- a/include/proto/log.h
+++ b/include/proto/log.h
@@ -183,6 +183,14 @@
 char *lf_port(char *dst, const struct sockaddr *sockaddr, size_t size, const struct logformat_node *node);
 
 
+/*
+ * Function to handle log header building (exported for sinks)
+ */
+char *update_log_hdr_rfc5424(const time_t time);
+char *update_log_hdr(const time_t time);
+char * get_format_pid_sep1(int format, size_t *len);
+char * get_format_pid_sep2(int format, size_t *len);
+
 #endif /* _PROTO_LOG_H */
 
 /*
diff --git a/include/proto/sink.h b/include/proto/sink.h
index 5028c25..bab9681 100644
--- a/include/proto/sink.h
+++ b/include/proto/sink.h
@@ -29,8 +29,10 @@
 
 struct sink *sink_find(const char *name);
 struct sink *sink_new_fd(const char *name, const char *desc, enum sink_fmt fmt, int fd);
-ssize_t __sink_write(struct sink *sink, const struct ist msg[], size_t nmsg);
-int sink_announce_dropped(struct sink *sink);
+ssize_t __sink_write(struct sink *sink, const struct ist msg[], size_t nmsg,
+                     int level, int facility, struct ist * tag,
+                     struct ist *pid, struct ist *sd);
+int sink_announce_dropped(struct sink *sink, int facility, struct ist *pid);
 
 
 /* tries to send <nmsg> message parts (up to 8, ignored above) from message
@@ -38,7 +40,9 @@
  * done here. Lost messages are accounted for in the sink's counter. If there
  * were lost messages, an attempt is first made to indicate it.
  */
-static inline void sink_write(struct sink *sink, const struct ist msg[], size_t nmsg)
+static inline void sink_write(struct sink *sink, const struct ist msg[], size_t nmsg,
+                              int level, int facility, struct ist * tag,
+                              struct ist *pid, struct ist *sd)
 {
 	ssize_t sent;
 
@@ -50,7 +54,7 @@
 		 * position.
 		 */
 		HA_RWLOCK_WRLOCK(LOGSRV_LOCK, &sink->ctx.lock);
-		sent = sink_announce_dropped(sink);
+		sent = sink_announce_dropped(sink, facility, pid);
 		HA_RWLOCK_WRUNLOCK(LOGSRV_LOCK, &sink->ctx.lock);
 
 		if (!sent) {
@@ -62,7 +66,7 @@
 	}
 
 	HA_RWLOCK_RDLOCK(LOGSRV_LOCK, &sink->ctx.lock);
-	sent = __sink_write(sink, msg, nmsg);
+	sent = __sink_write(sink, msg, nmsg, level, facility, tag, pid, sd);
 	HA_RWLOCK_RDUNLOCK(LOGSRV_LOCK, &sink->ctx.lock);
 
  fail:
diff --git a/include/types/sink.h b/include/types/sink.h
index e36a296..28b0379 100644
--- a/include/types/sink.h
+++ b/include/types/sink.h
@@ -56,8 +56,6 @@
 	const char *desc;          // sink description
 	enum sink_fmt fmt;         // format expected by the sink
 	enum sink_type type;       // type of storage
-	uint8_t syslog_facility;   // used by syslog format
-	uint8_t syslog_minlvl;     // used by syslog & short formats
 	uint32_t maxlen;           // max message length (truncated above)
 	struct {
 		__decl_hathreads(HA_RWLOCK_T lock); // shared/excl for dropped