mirror of
https://github.com/systemd/systemd.git
synced 2025-03-31 14:50:15 +03:00
journald: add a couple of static asserts checking logging constants
Whenever we include a log level or facility in a journal string field, make sure the compiler checks for us that that's actually the right thing to do.
This commit is contained in:
parent
d6f4302b66
commit
4850d39ab7
@ -794,6 +794,8 @@ int main(int argc, char* argv[]) {
|
||||
IOVEC_SET_STRING(iovec[j++], core_timestamp);
|
||||
|
||||
IOVEC_SET_STRING(iovec[j++], "MESSAGE_ID=fc2e22bc6ee647b6b90729ab34a250b1");
|
||||
|
||||
assert_cc(2 == LOG_CRIT);
|
||||
IOVEC_SET_STRING(iovec[j++], "PRIORITY=2");
|
||||
|
||||
/* Vacuum before we write anything again */
|
||||
|
@ -372,6 +372,7 @@ static int fill_iovec_perror_and_send(const char *message, int skip, struct iove
|
||||
|
||||
xsprintf(error, "ERRNO=%i", _saved_errno_);
|
||||
|
||||
assert_cc(3 == LOG_ERR);
|
||||
IOVEC_SET_STRING(iov[skip+0], "PRIORITY=3");
|
||||
IOVEC_SET_STRING(iov[skip+1], buffer);
|
||||
IOVEC_SET_STRING(iov[skip+2], error);
|
||||
|
@ -866,10 +866,12 @@ void server_driver_message(Server *s, sd_id128_t message_id, const char *format,
|
||||
assert(s);
|
||||
assert(format);
|
||||
|
||||
assert_cc(3 == LOG_FAC(LOG_DAEMON));
|
||||
IOVEC_SET_STRING(iovec[n++], "SYSLOG_FACILITY=3");
|
||||
IOVEC_SET_STRING(iovec[n++], "SYSLOG_IDENTIFIER=systemd-journald");
|
||||
|
||||
IOVEC_SET_STRING(iovec[n++], "_TRANSPORT=driver");
|
||||
assert_cc(6 == LOG_INFO);
|
||||
IOVEC_SET_STRING(iovec[n++], "PRIORITY=6");
|
||||
|
||||
if (!sd_id128_equal(message_id, SD_ID128_NULL)) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user