logger: Add NetBSD -m MSGID support for logging RFC5424 style
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
This commit is contained in:
parent
f2e1793cda
commit
e25f835a5a
@ -34,6 +34,7 @@
|
|||||||
.Nm
|
.Nm
|
||||||
.Op Fl chinsv
|
.Op Fl chinsv
|
||||||
.Op Fl f Ar FILE
|
.Op Fl f Ar FILE
|
||||||
|
.Op Fl m Ar MSGID
|
||||||
.Op Fl p Ar PRIO
|
.Op Fl p Ar PRIO
|
||||||
.Op Fl r Ar SIZE:NUM
|
.Op Fl r Ar SIZE:NUM
|
||||||
.Op Fl t Ar TAG
|
.Op Fl t Ar TAG
|
||||||
@ -68,6 +69,11 @@ as an alias for
|
|||||||
.It Fl i
|
.It Fl i
|
||||||
Log the process id of the logger process with each line
|
Log the process id of the logger process with each line
|
||||||
.Ql ( LOG_PID ) .
|
.Ql ( LOG_PID ) .
|
||||||
|
.It Fl m Ar MSGID
|
||||||
|
The MSGID used for the message. Requires RFC5424 support in
|
||||||
|
.Xr syslogd 8
|
||||||
|
for receiving the message and also for storing it properly in a log file
|
||||||
|
or sending remote in correctly formatted RFC5424 style.
|
||||||
.It Fl n
|
.It Fl n
|
||||||
Open log file immediately
|
Open log file immediately
|
||||||
.Ql ( LOG_NDELAY ) .
|
.Ql ( LOG_NDELAY ) .
|
||||||
|
12
src/logger.c
12
src/logger.c
@ -184,6 +184,7 @@ static int usage(int code)
|
|||||||
"\n"
|
"\n"
|
||||||
" -c Log to console (LOG_CONS) on failure\n"
|
" -c Log to console (LOG_CONS) on failure\n"
|
||||||
" -i Log the process ID of the logger process with each line (LOG_PID)\n"
|
" -i Log the process ID of the logger process with each line (LOG_PID)\n"
|
||||||
|
" -m MSGID The MSGID used for the message\n"
|
||||||
" -n Open log file immediately (LOG_NDELAY)\n"
|
" -n Open log file immediately (LOG_NDELAY)\n"
|
||||||
" -p PRIO Log message priority (numeric or facility.severity pair)\n"
|
" -p PRIO Log message priority (numeric or facility.severity pair)\n"
|
||||||
" -t TAG Log using the specified tag (defaults to user name)\n"
|
" -t TAG Log using the specified tag (defaults to user name)\n"
|
||||||
@ -212,10 +213,11 @@ int main(int argc, char *argv[])
|
|||||||
int rotate = 0;
|
int rotate = 0;
|
||||||
off_t size = 200 * 1024;
|
off_t size = 200 * 1024;
|
||||||
char *ident = NULL, *logfile = NULL;
|
char *ident = NULL, *logfile = NULL;
|
||||||
|
char *msgid = NULL;
|
||||||
char *sockpath = NULL;
|
char *sockpath = NULL;
|
||||||
char buf[512] = "";
|
char buf[512] = "";
|
||||||
|
|
||||||
while ((c = getopt(argc, argv, "?cf:inp:r:st:u:v")) != EOF) {
|
while ((c = getopt(argc, argv, "?cf:im:np:r:st:u:v")) != EOF) {
|
||||||
switch (c) {
|
switch (c) {
|
||||||
case 'c':
|
case 'c':
|
||||||
log_opts |= LOG_CONS;
|
log_opts |= LOG_CONS;
|
||||||
@ -229,6 +231,10 @@ int main(int argc, char *argv[])
|
|||||||
log_opts |= LOG_PID;
|
log_opts |= LOG_PID;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case 'm':
|
||||||
|
msgid = optarg;
|
||||||
|
break;
|
||||||
|
|
||||||
case 'n':
|
case 'n':
|
||||||
log_opts |= LOG_NDELAY;
|
log_opts |= LOG_NDELAY;
|
||||||
break;
|
break;
|
||||||
@ -302,9 +308,9 @@ int main(int argc, char *argv[])
|
|||||||
|
|
||||||
if (!buf[0]) {
|
if (!buf[0]) {
|
||||||
while ((fgets(buf, sizeof(buf), stdin)))
|
while ((fgets(buf, sizeof(buf), stdin)))
|
||||||
syslog_r(severity, &log, "%s", chomp(buf));
|
syslogp_r(severity, &log, msgid, NULL, "%s", chomp(buf));
|
||||||
} else
|
} else
|
||||||
syslog_r(severity, &log, "%s", buf);
|
syslogp_r(severity, &log, msgid, NULL, "%s", buf);
|
||||||
|
|
||||||
closelog_r(&log);
|
closelog_r(&log);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user