Set priority on every invokation. Shorten the check for openlog. - geomyidae - A small C-based gopherd. HTML git clone git://bitreich.org/geomyidae/ git://enlrupgkhuxnvlhsf6lc3fziv5h2hhfrinws65d7roiv6bfj7d652fid.onion/geomyidae/ DIR Log DIR Files DIR Refs DIR Tags DIR README DIR LICENSE --- DIR commit 42b52f54ede822d8e937025394d69702d5f910d3 DIR parent c555b684d623e711d266e6b15c5abba55ab02347 HTML Author: Christoph Lohmann <20h@r-36.net> Date: Thu, 18 Mar 2021 18:57:35 +0100 Set priority on every invokation. Shorten the check for openlog. Thanks escapeinsert for the proposal! Diffstat: M main.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) --- DIR diff --git a/main.c b/main.c @@ -48,6 +48,7 @@ enum { int glfd = -1; int dosyslog = 0; +int logpriority = LOG_INFO|LOG_DAEMON; int loglvl = 47; int revlookup = 1; char *logfile = NULL; @@ -110,7 +111,8 @@ logentry(char *host, char *port, char *qry, char *status) if (glfd >= 0 || dosyslog) { ahost = revlookup ? reverselookup(host) : host; if (dosyslog) { - syslog("[%s|%s|%s] %s\n", ahost, port, status, qry); + syslog(logpriority, "[%s|%s|%s] %s\n", ahost, port, + status, qry); } else { tim = time(0); ptr = gmtime(&tim); @@ -601,11 +603,8 @@ main(int argc, char *argv[]) } if (dosyslog) { - if (!dofork) { - openlog("geomyidae", LOG_CONS|LOG_PERROR, LOG_DAEMON|LOG_INFO); - } else { - openlog("geomyidae", LOG_NDELAY|LOG_PID, LOG_DAEMON|LOG_INFO); - } + openlog("geomyidae", dofork? LOG_NDELAY|LOG_PID \ + : LOG_CONS|LOG_PERROR, logpriority); } else if (logfile != NULL) { glfd = open(logfile, O_APPEND | O_WRONLY | O_CREAT, 0644); if (glfd < 0) {