static void driver_message(Server *s, sd_id128_t message_id, const char *format, ...) {
char mid[11 + 32 + 1];
char buffer[16 + LINE_MAX + 1];
- struct iovec iovec[N_IOVEC_META_FIELDS + 3];
+ struct iovec iovec[N_IOVEC_META_FIELDS + 4];
int n = 0;
va_list ap;
struct ucred ucred;
assert(format);
IOVEC_SET_STRING(iovec[n++], "PRIORITY=5");
+ IOVEC_SET_STRING(iovec[n++], "_TRANSPORT=driver");
memcpy(buffer, "MESSAGE=", 8);
va_start(ap, format);
static void process_syslog_message(Server *s, const char *buf, struct ucred *ucred, struct timeval *tv) {
char *message = NULL, *syslog_priority = NULL, *syslog_facility = NULL, *syslog_tag = NULL;
- struct iovec iovec[N_IOVEC_META_FIELDS + 4];
+ struct iovec iovec[N_IOVEC_META_FIELDS + 5];
unsigned n = 0;
int priority = LOG_USER | LOG_INFO;
char *tag = NULL;
if (s->forward_to_console)
forward_console(s, tag, buf, ucred);
+ IOVEC_SET_STRING(iovec[n++], "_TRANSPORT=syslog");
+
if (asprintf(&syslog_priority, "PRIORITY=%i", priority & LOG_PRIMASK) >= 0)
IOVEC_SET_STRING(iovec[n++], syslog_priority);
static void process_native_message(Server *s, const void *buffer, size_t buffer_size, struct ucred *ucred, struct timeval *tv) {
struct iovec *iovec = NULL;
- unsigned n = 0, m = 0, j;
+ unsigned n = 0, m = 0, j, tn = (unsigned) -1;
const char *p;
size_t remaining;
int priority = LOG_INFO;
struct iovec *c;
unsigned u;
- u = MAX((n+N_IOVEC_META_FIELDS) * 2U, 4U);
+ u = MAX((n+N_IOVEC_META_FIELDS+1) * 2U, 4U);
c = realloc(iovec, u * sizeof(struct iovec));
if (!c) {
log_error("Out of memory");
}
}
+ if (n <= 0)
+ goto finish;
+
+ tn = n++;
+ IOVEC_SET_STRING(iovec[tn], "_TRANSPORT=journal");
+
if (message) {
if (s->forward_to_syslog)
forward_syslog(s, priority, tag, message, ucred, tv);
dispatch_message(s, iovec, n, m, ucred, tv, priority);
- for (j = 0; j < n; j++)
+finish:
+ for (j = 0; j < n; j++) {
+ if (j == tn)
+ continue;
+
if (iovec[j].iov_base < buffer ||
(const uint8_t*) iovec[j].iov_base >= (const uint8_t*) buffer + buffer_size)
free(iovec[j].iov_base);
+ }
free(tag);
free(message);
}
static int stdout_stream_log(StdoutStream *s, const char *p) {
- struct iovec iovec[N_IOVEC_META_FIELDS + 4];
+ struct iovec iovec[N_IOVEC_META_FIELDS + 5];
char *message = NULL, *syslog_priority = NULL, *syslog_facility = NULL, *syslog_tag = NULL;
unsigned n = 0;
int priority;
if (s->forward_to_console || s->server->forward_to_console)
forward_console(s->server, s->tag, p, &s->ucred);
+ IOVEC_SET_STRING(iovec[n++], "_TRANSPORT=stdout");
+
if (asprintf(&syslog_priority, "PRIORITY=%i", priority & LOG_PRIMASK) >= 0)
IOVEC_SET_STRING(iovec[n++], syslog_priority);