mirror of
https://github.com/systemd/systemd.git
synced 2024-10-27 01:55:22 +03:00
log: fix shifting of facilities
This commit is contained in:
parent
29db583471
commit
7d76f31288
2
TODO
2
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
|
||||
|
@ -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) {
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
@ -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;
|
||||
|
15
src/logger.c
15
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:
|
||||
|
@ -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",
|
||||
|
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user