aboutsummaryrefslogtreecommitdiff
path: root/logger.c
diff options
context:
space:
mode:
authorOmar Polo <op@omarpolo.com>2023-08-07 09:34:19 +0000
committerOmar Polo <op@omarpolo.com>2023-08-07 09:34:19 +0000
commit9abba172b6f9ff373dd1e45d7b9587d3bdd0afcf (patch)
treeaa8a290791923b5de38b226bf4d942d0081d670f /logger.c
parent3a93c90445bc762cbef00d130feffd9a7f6b083f (diff)
add `log syslog facility' to use a different syslog(3) facility
Was requested ages ago by Karl Jeacle, now that there is some better support for configuring the logging there's no excuse to add this. It helps with filtering from syslog.d / syslog.conf.
Diffstat (limited to 'logger.c')
-rw-r--r--logger.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/logger.c b/logger.c
index d0e25c9..7949bd5 100644
--- a/logger.c
+++ b/logger.c
@@ -39,6 +39,7 @@
static int logfd = -1;
static int log_to_syslog = 1;
+static int facility = LOG_DAEMON;
static void logger_init(struct privsep *, struct privsep_proc *, void *);
static void logger_shutdown(void);
@@ -75,6 +76,11 @@ static int
logger_dispatch_parent(int fd, struct privsep_proc *p, struct imsg *imsg)
{
switch (imsg->hdr.type) {
+ case IMSG_LOG_FACILITY:
+ if (IMSG_DATA_SIZE(imsg) != sizeof(facility))
+ fatal("corrupted IMSG_LOG_SYSLOG");
+ memcpy(&facility, imsg->data, sizeof(facility));
+ break;
case IMSG_LOG_SYSLOG:
if (IMSG_DATA_SIZE(imsg) != sizeof(log_to_syslog))
fatal("corrupted IMSG_LOG_SYSLOG");
@@ -111,7 +117,7 @@ logger_dispatch_server(int fd, struct privsep_proc *p, struct imsg *imsg)
if (logfd != -1)
dprintf(logfd, "%s\n", msg);
if (log_to_syslog)
- syslog(LOG_DAEMON | LOG_NOTICE, "%s", msg);
+ syslog(facility | LOG_NOTICE, "%s", msg);
break;
default:
return -1;