diff options
author | June McEnroe <june@causal.agency> | 2020-08-15 16:14:21 -0400 |
---|---|---|
committer | June McEnroe <june@causal.agency> | 2020-08-15 16:14:21 -0400 |
commit | 449b0918ce9049366ea8ddb9b2569b457eb137a7 (patch) | |
tree | aa7571c94d7e9b58a2670736adfbbd74dc5f0bc5 | |
parent | Make log messages consistent (diff) | |
download | catsit-449b0918ce9049366ea8ddb9b2569b457eb137a7.tar.gz catsit-449b0918ce9049366ea8ddb9b2569b457eb137a7.zip |
Use only LOG_NOTICE and LOG_WARNING
These are the two priorities that go to a normal place (/var/log/messages) by default.
Diffstat (limited to '')
-rw-r--r-- | daemon.c | 12 | ||||
-rw-r--r-- | service.c | 38 |
2 files changed, 25 insertions, 25 deletions
diff --git a/daemon.c b/daemon.c index faf9150..095e962 100644 --- a/daemon.c +++ b/daemon.c @@ -62,7 +62,7 @@ static void configerr(bool exit, const char *format, ...) { if (exit) { verrx(EX_DATAERR, format, ap); } else { - vsyslog(LOG_ERR, format, ap); + vsyslog(LOG_WARNING, format, ap); } va_end(ap); } @@ -266,7 +266,7 @@ int main(int argc, char *argv[]) { if (daemonize) { error = daemon(0, 0); if (error) { - syslog(LOG_ERR, "daemon: %m"); + syslog(LOG_WARNING, "daemon: %m"); return EX_OSERR; } } @@ -327,7 +327,7 @@ int main(int argc, char *argv[]) { &mask ); if (nfds < 0 && errno != EINTR) { - syslog(LOG_ERR, "ppoll: %m"); + syslog(LOG_WARNING, "ppoll: %m"); continue; } @@ -338,7 +338,7 @@ int main(int argc, char *argv[]) { snprintf(buf, sizeof(buf), "%s", line); parseControl(buf); } - if (errno != EAGAIN) syslog(LOG_ERR, "read: %m"); + if (errno != EAGAIN) syslog(LOG_WARNING, "read: %m"); } if (nfds > 0) { @@ -367,7 +367,7 @@ int main(int argc, char *argv[]) { while (0 < (pid = waitpid(-1, &status, WNOHANG))) { serviceReap(pid, status); } - if (pid < 0 && errno != ECHILD) syslog(LOG_ERR, "waitpid: %m"); + if (pid < 0 && errno != ECHILD) syslog(LOG_WARNING, "waitpid: %m"); signals[SIGCHLD] = 0; } @@ -397,7 +397,7 @@ int main(int argc, char *argv[]) { int status; pid_t pid = wait(&status); if (pid < 0) { - syslog(LOG_ERR, "wait: %m"); + syslog(LOG_WARNING, "wait: %m"); continue; } serviceReap(pid, status); diff --git a/service.c b/service.c index 23d1de9..3246fef 100644 --- a/service.c +++ b/service.c @@ -114,24 +114,24 @@ err: void serviceStatus(struct Service *service) { if (service->state == Stop && service->intent == Stop) { - syslog(LOG_INFO, "%s[] is stopped", service->name); + syslog(LOG_NOTICE, "%s[] is stopped", service->name); } else if (service->state == Stop && service->intent == Start) { struct timespec now, timeleft; clock_gettime(CLOCK_MONOTONIC, &now); timespecsub(&service->restartDeadline, &now, &timeleft); syslog( - LOG_INFO, "%s[] is restarting in %lds", + LOG_NOTICE, "%s[] is restarting in %lds", service->name, (long)timeleft.tv_sec ); } else if (service->state == Stop && service->intent == Restart) { - syslog(LOG_INFO, "%s[] is restarting", service->name); + syslog(LOG_NOTICE, "%s[] is restarting", service->name); } else if (service->state == Start && service->intent == Start) { - syslog(LOG_INFO, "%s[%d] is started", service->name, service->pid); + syslog(LOG_NOTICE, "%s[%d] is started", service->name, service->pid); } else if (service->state == Start && service->intent == Stop) { - syslog(LOG_INFO, "%s[%d] is stopping", service->name, service->pid); + syslog(LOG_NOTICE, "%s[%d] is stopping", service->name, service->pid); } else if (service->state == Start && service->intent == Restart) { syslog( - LOG_INFO, "%s[%d] is stopping for restart", + LOG_NOTICE, "%s[%d] is stopping for restart", service->name, service->pid ); } @@ -159,11 +159,11 @@ void serviceStart(struct Service *service) { service->intent = Start; service->pid = fork(); if (service->pid < 0) { - syslog(LOG_ERR, "fork: %m"); + syslog(LOG_WARNING, "fork: %m"); return; } if (service->pid) { - syslog(LOG_INFO, "%s[%d] started", service->name, service->pid); + syslog(LOG_NOTICE, "%s[%d] started", service->name, service->pid); service->state = Start; return; } @@ -204,7 +204,7 @@ void serviceSignal(struct Service *service, int signal) { int error = kill(service->pid, signal); if (error) { syslog( - LOG_ERR, "kill(%s[%d], %s): %m", + LOG_WARNING, "kill(%s[%d], %s): %m", service->name, service->pid, sys_signame[signal] ); } @@ -224,28 +224,28 @@ void serviceRestart(struct Service *service) { } } -static void serviceLog(struct Service *service, int pri, const char *log) { - syslog(pri, "%s[%d]: %s", service->name, service->pid, log); +static void serviceLog(struct Service *service, const char *log) { + syslog(LOG_NOTICE, "%s[%d]: %s", service->name, service->pid, log); } void serviceRead(struct Service *service) { const char *out; while (NULL != (out = lineRead(&service->outLine, service->outPipe[0]))) { - serviceLog(service, LOG_INFO, out); + serviceLog(service, out); } - if (errno != EAGAIN) syslog(LOG_ERR, "read: %m"); + if (errno != EAGAIN) syslog(LOG_WARNING, "read: %m"); const char *err; while (NULL != (err = lineRead(&service->errLine, service->errPipe[0]))) { - serviceLog(service, LOG_NOTICE, err); + serviceLog(service, err); } - if (errno != EAGAIN) syslog(LOG_ERR, "read: %m"); + if (errno != EAGAIN) syslog(LOG_WARNING, "read: %m"); } static void serviceFlush(struct Service *service) { const char *out = lineFlush(&service->outLine); const char *err = lineFlush(&service->errLine); - if (out) serviceLog(service, LOG_INFO, out); - if (err) serviceLog(service, LOG_NOTICE, err); + if (out) serviceLog(service, out); + if (err) serviceLog(service, err); } void serviceReap(pid_t pid, int status) { @@ -285,11 +285,11 @@ void serviceReap(pid_t pid, int status) { // TODO: Determine if restart interval should be reset? setDeadline(service); syslog( - LOG_INFO, "%s[%d] restarting in %lds", + LOG_NOTICE, "%s[%d] restarting in %lds", service->name, pid, (long)service->restartInterval.tv_sec ); } else { - syslog(LOG_INFO, "%s[%d] stopped", service->name, pid); + syslog(LOG_NOTICE, "%s[%d] stopped", service->name, pid); } if (service->intent == Restart) { serviceStart(service); |