Audit logger(1)
1) Update manpage to current style 2) Line spacing 3) Local variable grouping 4) check for getline >= 0 instead of != -1 5) error message cleanup
This commit is contained in:
parent
d21a958d88
commit
0c2f19c210
2
README
2
README
|
@ -40,7 +40,7 @@ The following tools are implemented ('*' == finished, '#' == UTF-8 support,
|
||||||
=* kill yes none
|
=* kill yes none
|
||||||
=*| link yes none
|
=*| link yes none
|
||||||
=*| ln yes none
|
=*| ln yes none
|
||||||
=* logger yes none
|
=*| logger yes none
|
||||||
=* logname yes none
|
=* logname yes none
|
||||||
= ls no (-C), -S, -f, -m, -s, -x
|
= ls no (-C), -S, -f, -m, -s, -x
|
||||||
=*| md5sum non-posix none
|
=*| md5sum non-posix none
|
||||||
|
|
31
logger.1
31
logger.1
|
@ -1,4 +1,4 @@
|
||||||
.Dd December 4, 2014
|
.Dd March 7, 2015
|
||||||
.Dt LOGGER 1
|
.Dt LOGGER 1
|
||||||
.Os sbase
|
.Os sbase
|
||||||
.Sh NAME
|
.Sh NAME
|
||||||
|
@ -14,24 +14,31 @@
|
||||||
.Nm
|
.Nm
|
||||||
provides a shell command interface to the
|
provides a shell command interface to the
|
||||||
.Xr syslog 3
|
.Xr syslog 3
|
||||||
system log module.
|
system log module and writes each
|
||||||
|
.Ar message
|
||||||
|
to the log.
|
||||||
|
If no
|
||||||
|
.Ar message
|
||||||
|
is given,
|
||||||
|
.Nm
|
||||||
|
logs stdin.
|
||||||
.Sh OPTIONS
|
.Sh OPTIONS
|
||||||
.Bl -tag -width xxxxxxxxxxxx
|
.Bl -tag -width xxxxxxxxxxxx
|
||||||
.It Fl i
|
.It Fl i
|
||||||
Log the process ID of the logger process with each line.
|
Add the logger process ID to each line in the log.
|
||||||
.It Fl p Ar priority
|
.It Fl p Ar priority
|
||||||
Enter the message with the specified priority. They priority has to be
|
Set the message
|
||||||
specified symbolically as
|
.Ar priority
|
||||||
|
given symbolically as a
|
||||||
.Dq facility.level
|
.Dq facility.level
|
||||||
pair. The default is
|
pair. The default is
|
||||||
.Dq user.notice .
|
.Dq user.notice .
|
||||||
.It Fl s
|
.It Fl s
|
||||||
Log the message to standard error, as well as the system log.
|
Also log to stderr.
|
||||||
.It Fl t Ar tag
|
.It Fl t Ar tag
|
||||||
Mark every line in the log with the specified
|
Add
|
||||||
.Ar tag .
|
.Ar tag
|
||||||
.It Ar message
|
to each line in the log.
|
||||||
Write the message to the log; if not specified, standard input is logged.
|
|
||||||
.El
|
.El
|
||||||
.Sh SEE ALSO
|
.Sh SEE ALSO
|
||||||
.Xr syslogd 1 ,
|
.Xr syslogd 1 ,
|
||||||
|
@ -43,6 +50,6 @@ utility is compliant with the
|
||||||
.St -p1003.1-2008
|
.St -p1003.1-2008
|
||||||
specification.
|
specification.
|
||||||
.Pp
|
.Pp
|
||||||
The flags
|
The
|
||||||
.Op Fl ipst
|
.Op Fl ipst
|
||||||
are extensions to that specification.
|
flags are an extensions to that specification.
|
||||||
|
|
20
logger.c
20
logger.c
|
@ -18,8 +18,8 @@ decodetable(CODE *table, char *name)
|
||||||
if (!strcasecmp(name, c->c_name))
|
if (!strcasecmp(name, c->c_name))
|
||||||
return c->c_val;
|
return c->c_val;
|
||||||
eprintf("invalid priority name: %s\n", name);
|
eprintf("invalid priority name: %s\n", name);
|
||||||
/* NOTREACHED */
|
|
||||||
return -1;
|
return -1; /* not reached */
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
|
@ -32,6 +32,7 @@ decodepri(char *pri)
|
||||||
*lev++ = '\0';
|
*lev++ = '\0';
|
||||||
if (!*lev)
|
if (!*lev)
|
||||||
eprintf("invalid priority name: %s\n", pri);
|
eprintf("invalid priority name: %s\n", pri);
|
||||||
|
|
||||||
return (decodetable(facilitynames, fac) & LOG_FACMASK) |
|
return (decodetable(facilitynames, fac) & LOG_FACMASK) |
|
||||||
(decodetable(prioritynames, lev) & LOG_PRIMASK);
|
(decodetable(prioritynames, lev) & LOG_PRIMASK);
|
||||||
}
|
}
|
||||||
|
@ -45,10 +46,9 @@ usage(void)
|
||||||
int
|
int
|
||||||
main(int argc, char *argv[])
|
main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
|
size_t sz;
|
||||||
|
int logflags = 0, priority = LOG_NOTICE, i;
|
||||||
char *buf = NULL, *tag = NULL;
|
char *buf = NULL, *tag = NULL;
|
||||||
size_t sz = 0;
|
|
||||||
int logflags = 0, priority = LOG_NOTICE;
|
|
||||||
int i;
|
|
||||||
|
|
||||||
ARGBEGIN {
|
ARGBEGIN {
|
||||||
case 'i':
|
case 'i':
|
||||||
|
@ -69,13 +69,13 @@ main(int argc, char *argv[])
|
||||||
|
|
||||||
openlog(tag ? tag : getlogin(), logflags, 0);
|
openlog(tag ? tag : getlogin(), logflags, 0);
|
||||||
|
|
||||||
if (argc == 0) {
|
if (!argc) {
|
||||||
while (getline(&buf, &sz, stdin) != -1)
|
while (getline(&buf, &sz, stdin) >= 0)
|
||||||
syslog(priority, "%s", buf);
|
syslog(priority, "%s", buf);
|
||||||
if (ferror(stdin))
|
if (ferror(stdin))
|
||||||
eprintf("%s: read error:", "<stdin>");
|
eprintf("getline %s:", "<stdin>");
|
||||||
} else {
|
} else {
|
||||||
for (i = 0; i < argc; i++)
|
for (i = 0, sz = 0; i < argc; i++)
|
||||||
sz += strlen(argv[i]);
|
sz += strlen(argv[i]);
|
||||||
sz += argc;
|
sz += argc;
|
||||||
buf = ecalloc(1, sz);
|
buf = ecalloc(1, sz);
|
||||||
|
@ -86,6 +86,8 @@ main(int argc, char *argv[])
|
||||||
}
|
}
|
||||||
syslog(priority, "%s", buf);
|
syslog(priority, "%s", buf);
|
||||||
}
|
}
|
||||||
|
|
||||||
closelog();
|
closelog();
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user