diff options
author | Sami Kerola | 2014-08-09 02:04:50 +0200 |
---|---|---|
committer | Sami Kerola | 2014-08-15 22:52:12 +0200 |
commit | 35d3619793aad012bedc8ad7bff47218e2b5d663 (patch) | |
tree | 2ca17ada25d436f04487bacfde6d613bed5195b6 /misc-utils/logger.c | |
parent | logger: allow use of --id=ppid when logging locally (diff) | |
download | kernel-qcow2-util-linux-35d3619793aad012bedc8ad7bff47218e2b5d663.tar.gz kernel-qcow2-util-linux-35d3619793aad012bedc8ad7bff47218e2b5d663.tar.xz kernel-qcow2-util-linux-35d3619793aad012bedc8ad7bff47218e2b5d663.zip |
logger: remove openlog(3) options
One variable less, and more importantly bit operations become unnecessary
in if statements.
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
Diffstat (limited to 'misc-utils/logger.c')
-rw-r--r-- | misc-utils/logger.c | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/misc-utils/logger.c b/misc-utils/logger.c index d1b93d0bd..8ae00b26a 100644 --- a/misc-utils/logger.c +++ b/misc-utils/logger.c @@ -82,7 +82,6 @@ enum { struct logger_ctl { int fd; - int logflags; int pri; char *tag; char *unix_socket; @@ -92,7 +91,9 @@ struct logger_ctl { void (*syslogfp)(struct logger_ctl *ctl, char *msg); unsigned int prio_prefix:1, /* read priority from intput */ + pid:1, /* print PID, or PPID if it is enabled as well*/ ppid:1, /* include PPID instead of PID */ + stderr_printout:1, /* output message to stderr */ rfc5424_time:1, /* include time stamp */ rfc5424_tq:1, /* include time quality markup */ rfc5424_host:1; /* include hostname */ @@ -291,7 +292,7 @@ static pid_t get_process_id(struct logger_ctl *ctl) { pid_t id = 0; - if (ctl->logflags & LOG_PID) + if (ctl->pid) id = ctl->ppid ? getppid() : getpid(); return id; } @@ -323,7 +324,7 @@ static void syslog_rfc3164(struct logger_ctl *ctl, char *msg) if (write_all(ctl->fd, buf, len) < 0) warn(_("write failed")); - if (ctl->logflags & LOG_PERROR) + if (ctl->stderr_printout) fprintf(stderr, "%s\n", buf); free(hostname); @@ -390,7 +391,7 @@ static void syslog_rfc5424(struct logger_ctl *ctl, char *msg) if (write_all(ctl->fd, buf, len) < 0) warn(_("write failed")); - if (ctl->logflags & LOG_PERROR) + if (ctl->stderr_printout) fprintf(stderr, "%s\n", buf); free(hostname); @@ -439,7 +440,7 @@ static void syslog_local(struct logger_ctl *ctl, char *msg) len = xasprintf(&buf, "<%d>%s %s%s: %s", ctl->pri, time, tag, pid, msg); if (write_all(ctl->fd, buf, len) < 0) warn(_("write failed")); - if (ctl->logflags & LOG_PERROR) + if (ctl->stderr_printout) fprintf(stderr, "%s\n", buf); free(buf); } @@ -557,7 +558,6 @@ int main(int argc, char **argv) { struct logger_ctl ctl = { .fd = -1, - .logflags = 0, .ppid = 0, .pri = LOG_NOTICE, .prio_prefix = 0, @@ -611,7 +611,7 @@ int main(int argc, char **argv) stdout_reopened = 1; break; case 'i': /* log process id also */ - ctl.logflags |= LOG_PID; + ctl.pid = 1; if (optarg) { const char *p = optarg; @@ -629,7 +629,7 @@ int main(int argc, char **argv) ctl.pri = pencode(optarg); break; case 's': /* log to standard error */ - ctl.logflags |= LOG_PERROR; + ctl.stderr_printout = 1; break; case 't': /* tag */ ctl.tag = optarg; |