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/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: