about summary refs log tree commit diff
path: root/vlogger.c
diff options
context:
space:
mode:
authorDuncaen <mail@duncano.de>2018-06-22 15:04:47 +0200
committerDuncaen <mail@duncano.de>2018-06-22 16:53:50 +0200
commit64acdc39935548eeca43fd3c31a6e59faa008a9b (patch)
tree35b56a815d23c75b5102b0a2275592c6d6feba6e /vlogger.c
parent3095ba6629084a92542631fe8402070e5f089161 (diff)
downloadrunit-void-64acdc39935548eeca43fd3c31a6e59faa008a9b.tar.gz
runit-void-64acdc39935548eeca43fd3c31a6e59faa008a9b.tar.xz
runit-void-64acdc39935548eeca43fd3c31a6e59faa008a9b.zip
vlogger: add logger(1) compatible -s and -i flag, and -S to force syslog
Diffstat (limited to 'vlogger.c')
-rw-r--r--vlogger.c13
1 files changed, 9 insertions, 4 deletions
diff --git a/vlogger.c b/vlogger.c
index a3f7a08..0393bc8 100644
--- a/vlogger.c
+++ b/vlogger.c
@@ -79,6 +79,8 @@ main(int argc, char *argv[])
 	char *p, *argv0;
 	char *tag = "vlogger";
 	int c;
+	int Sflag = 0;
+	int logflags = 0;
 	int facility = LOG_DAEMON;
 	int level = LOG_INFO;
 
@@ -96,23 +98,26 @@ main(int argc, char *argv[])
 		}
 	}
 
-	while ((c = getopt(argc, argv, "p:t:")) != -1)
+	while ((c = getopt(argc, argv, "ip:Sst:")) != -1)
 		switch (c) {
+		case 'i': logflags |= LOG_PID; break;
 		case 'p': strpriority(optarg, &facility, &level); break;
+		case 'S': Sflag++; break;
+		case 's': logflags |= LOG_PERROR; break;
 		case 't': tag = optarg; break;
 		default:
 usage:
-			fprintf(stderr, "usage: vlogger [-p priority] [-t tag]\n");
+			fprintf(stderr, "usage: vlogger [-isS] [-p pri] [-t tag]\n");
 			exit(1);
 		}
 
-	if (access("/etc/vlogger", X_OK) != -1) {
+	if (!Sflag && access("/etc/vlogger", X_OK) != -1) {
 		execl("/etc/vlogger", argv0, tag, (char *)0);
 		fprintf(stderr, "vlogger: exec: %s\n", strerror(errno));
 		exit(1);
 	}
 
-	openlog(tag, 0, facility);
+	openlog(tag, logflags, facility);
 
 	char *line = NULL;
 	size_t linelen = 0;