logger: Add NetBSD -c option for LOG_CONS

Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
This commit is contained in:
Joachim Nilsson 2019-11-07 21:08:01 +01:00
parent fff4368e80
commit d3461fd6a3
2 changed files with 14 additions and 2 deletions

View File

@ -32,7 +32,7 @@
.Nd Send messages to system log, or a log file
.Sh SYNOPSIS
.Nm
.Op Fl hsv
.Op Fl chsv
.Op Fl f Ar FILE
.Op Fl p Ar PRIO
.Op Fl r Ar SIZE:NUM
@ -51,6 +51,13 @@ reads input from
.Sh OPTIONS
This program follows the usual UNIX command line syntax:
.Bl -tag -width Ds
.It Fl c
Log to console
.Ql ( LOG_CONS )
if
.Fn syslog
fails to send message to
.Xr syslogd 8 .
.It Fl f Ar FILE
Log file to write messages to, instead of syslog daemon.
.Nm

View File

@ -182,6 +182,7 @@ static int usage(int code)
"\n"
"Write MESSAGE (or line-by-line stdin) to syslog, or file (with logrotate).\n"
"\n"
" -c Log to console (LOG_CONS) on failure\n"
" -p PRIO Log message priority (numeric or facility.severity pair)\n"
" -t TAG Log using the specified tag (defaults to user name)\n"
" -s Log to stderr as well as the system log\n"
@ -212,8 +213,12 @@ int main(int argc, char *argv[])
char *sockpath = NULL;
char buf[512] = "";
while ((c = getopt(argc, argv, "?f:p:r:st:u:v")) != EOF) {
while ((c = getopt(argc, argv, "?cf:p:r:st:u:v")) != EOF) {
switch (c) {
case 'c':
log_opts |= LOG_CONS;
break;
case 'f':
logfile = optarg;
break;