From 288f526f23eb6270f6c902883e9a3092dc4972fa Mon Sep 17 00:00:00 2001 From: Duncan Overbruck Date: Sun, 28 Feb 2021 16:45:23 +0100 Subject: vlogger: behave like logger(1) if argv[0] is "logger" --- vlogger.8 | 20 ++++++++++++-------- vlogger.c | 5 +++++ 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 #include +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) -- cgit 1.4.1