From 0f39e1f97ada46752ed07c1e1033fe4e062c8da9 Mon Sep 17 00:00:00 2001 From: Duncan Overbruck Date: Sun, 25 Aug 2019 13:07:10 +0200 Subject: vlogger: use the same defaults as logger(1) --- vlogger.8 | 5 ++++- vlogger.c | 8 ++++---- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/vlogger.8 b/vlogger.8 index d2e88ff..d958ae7 100644 --- a/vlogger.8 +++ b/vlogger.8 @@ -66,7 +66,7 @@ See or .Xr syslog 3 . The default is -.Pa daemon.info . +.Dq user.notice . .It Fl S Force .Nm @@ -87,6 +87,9 @@ Defines the .Pa ident which is used as prefix for each log message or passed as first argument to .Pa /etc/vlogger . +The default is the +.Ev LOGNAME +environment variable. .It Ar message Write the .Ar message diff --git a/vlogger.c b/vlogger.c index 949fb5b..cba5183 100644 --- a/vlogger.c +++ b/vlogger.c @@ -78,12 +78,12 @@ main(int argc, char *argv[]) { char buf[1024]; char *p, *argv0; - char *tag = "vlogger"; + char *tag = NULL; int c; int Sflag = 0; int logflags = 0; - int facility = LOG_DAEMON; - int level = LOG_INFO; + int facility = LOG_USER; + int level = LOG_NOTICE; argv0 = *argv; @@ -135,7 +135,7 @@ main(int argc, char *argv[]) exit(1); } - openlog(tag, logflags, facility); + openlog(tag ? tag : getlogin(), logflags, facility); if (argc > 0) { size_t len; -- cgit 1.4.1 From 6d251bc654f5cc29070536aae58f0aaf6e7d2f39 Mon Sep 17 00:00:00 2001 From: Duncan Overbruck Date: Sun, 25 Aug 2019 13:08:31 +0200 Subject: vlogger: fix uninitialized value warnings found with clang scan-build --- vlogger.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vlogger.c b/vlogger.c index cba5183..d820991 100644 --- a/vlogger.c +++ b/vlogger.c @@ -121,7 +121,7 @@ main(int argc, char *argv[]) if (!Sflag && access("/etc/vlogger", X_OK) != -1) { CODE *cp; - const char *sfacility, *slevel; + const char *sfacility = "", *slevel = ""; for (cp = prioritynames; cp->c_name; cp++) { if (cp->c_val == level) slevel = cp->c_name; -- cgit 1.4.1 From ca0f18e801715d921f717287dd67718cfcb2f3b0 Mon Sep 17 00:00:00 2001 From: Duncan Overbruck Date: Sun, 25 Aug 2019 13:10:06 +0200 Subject: vlogger: no need to duplicate the tag name from service path --- vlogger.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vlogger.c b/vlogger.c index d820991..c886239 100644 --- a/vlogger.c +++ b/vlogger.c @@ -94,7 +94,7 @@ main(int argc, char *argv[]) *p = '\0'; if ((p = strrchr(pwd, '/')) && strncmp(p+1, "log", 3) == 0 && (*p = '\0', (p = strrchr(pwd, '/'))) && (*(p+1) != '\0')) { - tag = strdup(p+1); + tag = p+1; } } } -- cgit 1.4.1 From b25043d6e1e75f29b438ae23a31950ab5401a0cd Mon Sep 17 00:00:00 2001 From: Duncan Overbruck Date: Sun, 25 Aug 2019 13:15:36 +0200 Subject: vlogger.8: fix -f description --- vlogger.8 | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/vlogger.8 b/vlogger.8 index d958ae7..820cf3b 100644 --- a/vlogger.8 +++ b/vlogger.8 @@ -45,7 +45,9 @@ The options are as follows: .It Fl f Ar file Read lines from the specified .Ar file . -This +This option cannot be combine +.Ar message +arguments. .It Fl i Log the PID of the .Nm -- cgit 1.4.1 From 06c1ad4f8b54affde57d928c9557034969c36e21 Mon Sep 17 00:00:00 2001 From: Duncan Overbruck Date: Sun, 25 Aug 2019 13:37:01 +0200 Subject: vlogger: force to use syslog if message arguments are given --- vlogger.8 | 40 +++++++++++++++++++++++++++++----------- vlogger.c | 3 +++ 2 files changed, 32 insertions(+), 11 deletions(-) diff --git a/vlogger.8 b/vlogger.8 index 820cf3b..b7919d9 100644 --- a/vlogger.8 +++ b/vlogger.8 @@ -12,17 +12,35 @@ .Op Fl t Ar tag .Op Ar message ... .Sh DESCRIPTION -By default, +The .Nm -reads lines from +utility writes messages to the system log. +.Pp +With +.Ar message +arguments +.Nm +will always write messages to the system log. +Without +.Ar message +arguments +.Nm +reads messages from .Dv stdin -and sends them to syslog. -If the file +or the file specified with the +.Fl f +flag. +If the .Pa /etc/vlogger -exists and is executable it is executed with -.Ar tag -as only argument and replaces -.Nm . +executable exists +.Nm +executes it with +.Ar tag , +level +and priority as arguments, +replacing the +.Nm +process. .Pp If .Nm @@ -34,10 +52,10 @@ supervision suite it uses the service name as default As example if .Nm is linked to -.Dv /var/service/foo/log/run +.Pa /var/service/foo/log/run it uses -.Dv foo -as default +.Dq foo +as .Ar tag . .Pp The options are as follows: diff --git a/vlogger.c b/vlogger.c index c886239..64f1a2e 100644 --- a/vlogger.c +++ b/vlogger.c @@ -119,6 +119,9 @@ main(int argc, char *argv[]) argc -= optind; argv += optind; + if (argc > 0) + Sflag++; + if (!Sflag && access("/etc/vlogger", X_OK) != -1) { CODE *cp; const char *sfacility = "", *slevel = ""; -- cgit 1.4.1