about summary refs log tree commit diff
diff options
context:
space:
mode:
authorDuncan Overbruck <mail@duncano.de>2021-02-28 16:45:23 +0100
committerDuncan Overbruck <github@duncano.de>2021-03-13 23:55:15 +0100
commit288f526f23eb6270f6c902883e9a3092dc4972fa (patch)
tree5a927c1b359417e61c6e9c1fd7c52ef0e1f954b0
parent3db879ba2364eb185d9ad38c1aa7139806dd19c9 (diff)
downloadrunit-void-288f526f23eb6270f6c902883e9a3092dc4972fa.tar.gz
runit-void-288f526f23eb6270f6c902883e9a3092dc4972fa.tar.xz
runit-void-288f526f23eb6270f6c902883e9a3092dc4972fa.zip
vlogger: behave like logger(1) if argv[0] is "logger"
-rw-r--r--vlogger.820
-rw-r--r--vlogger.c5
2 files changed, 17 insertions, 8 deletions
diff --git a/vlogger.8 b/vlogger.8
index 3a6b204..24a45c8 100644
--- a/vlogger.8
+++ b/vlogger.8
@@ -14,13 +14,15 @@
 .Sh DESCRIPTION
 The
 .Nm
-utility writes messages to the system log.
+utility writes messages to the system log or an arbitrary executable.
 .Pp
-With
-.Ar message
-arguments
+If
 .Nm
-will always write messages to the system log.
+is executed as
+.Nm logger
+it will always use the system log and behave like the regular
+.Xr logger 1 .
+.Pp
 Without
 .Ar message
 arguments
@@ -36,8 +38,10 @@ executable exists
 .Nm
 executes it with
 .Ar tag ,
-level
-and priority as arguments,
+.Ar level
+and
+.Ar facility
+as arguments,
 replacing the
 .Nm
 process.
@@ -117,7 +121,7 @@ environment variable.
 .It Ar message
 Write the
 .Ar message
-to the log.
+to the system log.
 .El
 .Sh FACILITIES
 .Bl -tag -width 11n -compact
diff --git a/vlogger.c b/vlogger.c
index e61f601..801c1d3 100644
--- a/vlogger.c
+++ b/vlogger.c
@@ -6,6 +6,8 @@
 #include <unistd.h>
 #include <limits.h>
 
+extern char *__progname;
+
 static char pwd[PATH_MAX];
 
 typedef struct {
@@ -99,6 +101,9 @@ main(int argc, char *argv[])
 				level = LOG_NOTICE;
 			}
 		}
+	} else if (strcmp(__progname, "logger") == 0) {
+		/* behave just like logger(1) and only use syslog */
+		Sflag++;
 	}
 
 	while ((c = getopt(argc, argv, "f:ip:Sst:")) != -1)