1
0
mirror of https://github.com/systemd/systemd.git synced 2024-12-23 21:35:11 +03:00

journal: introduce mandatory sd_journal_printf() priority parameter

This commit is contained in:
Lennart Poettering 2011-12-17 01:32:49 +01:00
parent cab8ac6083
commit d0bbc21caa
2 changed files with 13 additions and 10 deletions

View File

@ -52,30 +52,33 @@ retry:
return fd;
}
int sd_journal_print(const char *format, ...) {
int sd_journal_print(int priority, const char *format, ...) {
int r;
va_list ap;
va_start(ap, format);
r = sd_journal_printv(format, ap);
r = sd_journal_printv(priority, format, ap);
va_end(ap);
return r;
}
int sd_journal_printv(const char *format, va_list ap) {
char buffer[8 + LINE_MAX];
struct iovec iov;
int sd_journal_printv(int priority, const char *format, va_list ap) {
char buffer[8 + LINE_MAX], p[11];
struct iovec iov[2];
snprintf(p, sizeof(p), "PRIORITY=%i", priority & LOG_PRIMASK);
char_array_0(p);
memcpy(buffer, "MESSAGE=", 8);
vsnprintf(buffer+8, sizeof(buffer) - 8, format, ap);
char_array_0(buffer);
zero(iov);
IOVEC_SET_STRING(iov, buffer);
IOVEC_SET_STRING(iov[0], buffer);
IOVEC_SET_STRING(iov[1], p);
return sd_journal_sendv(&iov, 1);
return sd_journal_sendv(iov, 2);
}
int sd_journal_send(const char *format, ...) {

View File

@ -45,8 +45,8 @@
/* Write to daemon */
int sd_journal_print(const char *format, ...) __attribute__ ((format (printf, 1, 2)));
int sd_journal_printv(const char *format, va_list ap);
int sd_journal_print(int piority, const char *format, ...) __attribute__ ((format (printf, 2, 3)));
int sd_journal_printv(int priority, const char *format, va_list ap);
int sd_journal_send(const char *format, ...) __attribute__((sentinel));
int sd_journal_sendv(const struct iovec *iov, int n);