* Copyright (c) 1983 Regents of the University of California.
* Redistribution and use in source and binary forms are permitted
* provided that this notice is preserved and that due credit is given
* to the University of California at Berkeley. The name of the University
* may not be used to endorse or promote products derived from this
* software without specific prior written permission. This software
* is provided ``as is'' without express or implied warranty.
"@(#) Copyright (c) 1983 Regents of the University of California.\n\
static char sccsid
[] = "@(#)logger.c 6.5 (Berkeley) %G%";
** LOGGER -- read and log utility
** This routine reads from an input and arranges to write the
** result on the system log, along with a useful tag.
char *tag
, buf
[200], *getlogin();
while ((ch
= getopt(argc
, argv
, "f:ip:t:")) != EOF
)
case 'f': /* file to log */
if (freopen(optarg
, "r", stdin
) == NULL
) {
case 'i': /* log process id also */
openlog(tag
? tag
: getlogin(), logflags
, 0);
/* log input line if appropriate */
for (p
= buf
, endp
= buf
+ sizeof(buf
) - 1;;) {
while (fgets(buf
, sizeof(buf
), stdin
) != NULL
)
struct code PriNames
[] = {
struct code FacNames
[] = {
* Decode a symbolic name to a numeric value
for (save
= s
; *s
&& *s
!= '.'; ++s
);
fac
= decode(save
, FacNames
);
bailout("unknown facility name: ", save
);
lev
= decode(s
, PriNames
);
bailout("unknown priority name: ", save
);
return ((lev
& LOG_PRIMASK
) | (fac
& LOG_FACMASK
));
for (c
= codetab
; c
->c_name
; c
++)
if (!strcasecmp(name
, c
->c_name
))
fprintf(stderr
, "logger: %s%s\n", msg
, arg
);
fputs("logger: [-i] [-f file] [-p pri] [-t tag] [ message ... ]\n",