chiark / gitweb /
log: fix shifting of facilities
authorLennart Poettering <lennart@poettering.net>
Thu, 31 Mar 2011 19:22:44 +0000 (21:22 +0200)
committerLennart Poettering <lennart@poettering.net>
Thu, 31 Mar 2011 19:22:44 +0000 (21:22 +0200)
TODO
src/execute.c
src/load-fragment.c
src/log.c
src/logger.c
src/util.c
src/util.h

diff --git a/TODO b/TODO
index c1cdf1c6c35365bfdfe513118d0f50b8b2eec7ea..c5222baaf02f872d25876dcef69147f739125fa4 100644 (file)
--- 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
index b7ae522692f452f23b9107255e76aec5d07ac47d..80c649f1c67d2f34a298f5c13292696014edc95d 100644 (file)
@@ -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) {
index 343525665a60a955cbfc17b5cc303e72ffa9d0f9..05d858e86a74e9a57f51b58f5b80f02437e3f754 100644 (file)
@@ -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;
 }
 
index 4ec6b73888279217f1dd316b12965863753cc55f..95c27656b70a6195fbdba39d1aa19e9eb62d6541 100644 (file)
--- 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;
index 710dfed33bc9b12a0e0a6bfef38e41aef6507ff8..eb62688f40aeba0d1bed9ed4e009712a17bc9fc5 100644 (file)
@@ -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:
index 5a5cdceab42c5c893ac0ccd118cd456b1fdf9061..2a5f3074b650f0cf538256c4eb10e9b11f924637 100644 (file)
@@ -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",
index dfbfa8b04dd73c6ae46ff77088a7b51d8316f1c1..cc63dd1a8302f7cc15749cf81c12753aa602f97d 100644 (file)
@@ -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);