| Set priority on every invokation. Shorten the check for openlog. - geomyidae - … | |
| git clone git://bitreich.org/geomyidae/ git://enlrupgkhuxnvlhsf6lc3fziv5h2hhfri… | |
| Log | |
| Files | |
| Refs | |
| Tags | |
| README | |
| LICENSE | |
| --- | |
| commit 42b52f54ede822d8e937025394d69702d5f910d3 | |
| parent c555b684d623e711d266e6b15c5abba55ab02347 | |
| Author: Christoph Lohmann <[email protected]> | |
| 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(-) | |
| --- | |
| 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|L… | |
| - } else { | |
| - openlog("geomyidae", LOG_NDELAY|LOG_PID, LOG_DAEMON|LO… | |
| - } | |
| + 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) { |