From: Lennart Poettering Date: Thu, 31 Mar 2011 19:22:44 +0000 (+0200) Subject: log: fix shifting of facilities X-Git-Tag: v22~4 X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=7d76f312889d54dcfe6fdde6eb055e890e7a615b;p=systemd log: fix shifting of facilities --- diff --git a/TODO b/TODO index c1cdf1c6..c5222baa 100644 --- a/TODO +++ b/TODO @@ -19,6 +19,8 @@ F15: * NM should pull in network.target, ntpd should pull in rtc-set.target. +* bluetooth should be possible to disable + * fix alsa mixer restore to not print error when no config is stored * ConditionDirectoryNotEmpty= needs to be documented diff --git a/src/execute.c b/src/execute.c index b7ae5226..80c649f1 100644 --- a/src/execute.c +++ b/src/execute.c @@ -1650,7 +1650,7 @@ void exec_context_dump(ExecContext *c, FILE* f, const char *prefix) { fprintf(f, "%sSyslogFacility: %s\n" "%sSyslogLevel: %s\n", - prefix, log_facility_to_string(LOG_FAC(c->syslog_priority)), + prefix, log_facility_unshifted_to_string(c->syslog_priority >> 3), prefix, log_level_to_string(LOG_PRI(c->syslog_priority))); if (c->capabilities) { diff --git a/src/load-fragment.c b/src/load-fragment.c index 34352566..05d858e8 100644 --- a/src/load-fragment.c +++ b/src/load-fragment.c @@ -584,12 +584,12 @@ static int config_parse_facility( assert(rvalue); assert(data); - if ((x = log_facility_from_string(rvalue)) < 0) { + if ((x = log_facility_unshifted_from_string(rvalue)) < 0) { log_error("[%s:%u] Failed to parse log facility, ignoring: %s", filename, line, rvalue); return 0; } - *o = LOG_MAKEPRI(x, LOG_PRI(*o)); + *o = (x << 3) | LOG_PRI(*o); return 0; } @@ -617,7 +617,7 @@ static int config_parse_level( return 0; } - *o = LOG_MAKEPRI(LOG_FAC(*o), x); + *o = (*o & LOG_FACMASK) | x; return 0; } diff --git a/src/log.c b/src/log.c index 4ec6b738..95c27656 100644 --- a/src/log.c +++ b/src/log.c @@ -378,8 +378,8 @@ static int log_dispatch( return 0; /* Patch in LOG_DAEMON facility if necessary */ - if (LOG_FAC(level) == 0) - level = LOG_MAKEPRI(LOG_DAEMON, LOG_PRI(level)); + if ((level & LOG_FACMASK) == 0) + level = LOG_DAEMON | LOG_PRI(level); do { char *e; diff --git a/src/logger.c b/src/logger.c index 710dfed3..eb62688f 100644 --- a/src/logger.c +++ b/src/logger.c @@ -143,23 +143,12 @@ static int stream_log(Stream *s, char *p, usec_t ts) { if (s->prefix) parse_priority(&p, &priority); - if (s->prefix && - p[0] == '<' && - p[1] >= '0' && p[1] <= '7' && - p[2] == '>') { - - /* Detected priority prefix */ - priority = LOG_MAKEPRI(LOG_FAC(priority), (p[1] - '0')); - - p += 3; - } - if (*p == 0) return 0; /* Patch in LOG_USER facility if necessary */ - if (LOG_FAC(priority) == 0) - priority = LOG_MAKEPRI(LOG_USER, LOG_PRI(priority)); + if ((priority & LOG_FACMASK) == 0) + priority = LOG_USER | LOG_PRI(priority); /* * The format glibc uses to talk to the syslog daemon is: diff --git a/src/util.c b/src/util.c index 5a5cdcea..2a5f3074 100644 --- a/src/util.c +++ b/src/util.c @@ -4211,7 +4211,7 @@ static const char *const sigchld_code_table[] = { DEFINE_STRING_TABLE_LOOKUP(sigchld_code, int); -static const char *const log_facility_table[LOG_NFACILITIES] = { +static const char *const log_facility_unshifted_table[LOG_NFACILITIES] = { [LOG_FAC(LOG_KERN)] = "kern", [LOG_FAC(LOG_USER)] = "user", [LOG_FAC(LOG_MAIL)] = "mail", @@ -4234,7 +4234,7 @@ static const char *const log_facility_table[LOG_NFACILITIES] = { [LOG_FAC(LOG_LOCAL7)] = "local7" }; -DEFINE_STRING_TABLE_LOOKUP(log_facility, int); +DEFINE_STRING_TABLE_LOOKUP(log_facility_unshifted, int); static const char *const log_level_table[] = { [LOG_EMERG] = "emerg", diff --git a/src/util.h b/src/util.h index dfbfa8b0..cc63dd1a 100644 --- a/src/util.h +++ b/src/util.h @@ -406,8 +406,8 @@ int ioprio_class_from_string(const char *s); const char *sigchld_code_to_string(int i); int sigchld_code_from_string(const char *s); -const char *log_facility_to_string(int i); -int log_facility_from_string(const char *s); +const char *log_facility_unshifted_to_string(int i); +int log_facility_unshifted_from_string(const char *s); const char *log_level_to_string(int i); int log_level_from_string(const char *s);