summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2011-03-31 21:22:44 +0200
committerLennart Poettering <lennart@poettering.net>2011-03-31 21:22:44 +0200
commit7d76f312889d54dcfe6fdde6eb055e890e7a615b (patch)
tree7ef1439ab07d28ca0a530d5643eec5bf0de33a40
parent29db583471f019ed9939a90966b3e194a9560e7e (diff)
log: fix shifting of facilities
-rw-r--r--TODO2
-rw-r--r--src/execute.c2
-rw-r--r--src/load-fragment.c6
-rw-r--r--src/log.c4
-rw-r--r--src/logger.c15
-rw-r--r--src/util.c4
-rw-r--r--src/util.h4
7 files changed, 14 insertions, 23 deletions
diff --git a/TODO b/TODO
index c1cdf1c6c3..c5222baaf0 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 b7ae522692..80c649f1c6 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 343525665a..05d858e86a 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 4ec6b73888..95c27656b7 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 710dfed33b..eb62688f40 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 5a5cdceab4..2a5f3074b6 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 dfbfa8b04d..cc63dd1a83 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);