about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--vlogger.849
-rw-r--r--vlogger.c15
2 files changed, 45 insertions, 19 deletions
diff --git a/vlogger.8 b/vlogger.8
index d2e88ff..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:
@@ -45,7 +63,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
@@ -66,7 +86,7 @@ See
 or
 .Xr syslog 3 .
 The default is
-.Pa daemon.info .
+.Dq user.notice .
 .It Fl S
 Force
 .Nm
@@ -87,6 +107,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..64f1a2e 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;
 
@@ -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;
 			}
 		}
 	}
@@ -119,9 +119,12 @@ 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;
+		const char *sfacility = "", *slevel = "";
 		for (cp = prioritynames; cp->c_name; cp++) {
 			if (cp->c_val == level)
 				slevel = cp->c_name;
@@ -135,7 +138,7 @@ main(int argc, char *argv[])
 		exit(1);
 	}
 
-	openlog(tag, logflags, facility);
+	openlog(tag ? tag : getlogin(), logflags, facility);
 
 	if (argc > 0) {
 		size_t len;