rename logtee->logtap

This commit is contained in:
Daniel Barlow 2024-09-18 20:58:02 +01:00
parent 707a471bc2
commit 17630f2678
2 changed files with 8 additions and 6 deletions

View File

@ -1,5 +1,5 @@
TARGETS=logtee # ship-zinc backfill TARGETS=logtap
default: $(TARGETS) default: $(TARGETS)
install: $(TARGETS) install: $(TARGETS)
install -Dt $(PREFIX)/bin/ logtee install -Dt $(PREFIX)/bin/ logtap

View File

@ -11,6 +11,8 @@
#include <sys/un.h> #include <sys/un.h>
#include <errno.h> #include <errno.h>
#define PROGRAM_NAME "logtap"
#ifdef _GNU_SOURCE #ifdef _GNU_SOURCE
#include <error.h> #include <error.h>
#else #else
@ -19,7 +21,7 @@ static void error(int status, int errnum, const char * fmt, ...) {
va_list ap; va_list ap;
va_start(ap, fmt); va_start(ap, fmt);
fprintf(stderr, "logtee: "); fprintf(stderr, PROGRAM_NAME ": ");
vfprintf(stderr, fmt, ap); vfprintf(stderr, fmt, ap);
if(errnum) fprintf(stderr, ": %s", strerror(errnum)); if(errnum) fprintf(stderr, ": %s", strerror(errnum));
fprintf(stderr, "\n"); fprintf(stderr, "\n");
@ -41,7 +43,7 @@ int open_shipper_socket(char *pathname) {
if(fd >= 0) { if(fd >= 0) {
if(connect(fd, (struct sockaddr *) &sa, sizeof sa)) { if(connect(fd, (struct sockaddr *) &sa, sizeof sa)) {
if((fail_count % 30) == 0) if((fail_count % 30) == 0)
printf("logtee: cannot connect socket \"%s\": %s\n", printf(PROGRAM_NAME ": cannot connect socket \"%s\": %s\n",
pathname, pathname,
strerror(errno)); strerror(errno));
@ -73,7 +75,7 @@ int main(int argc, char * argv[]) {
int tee_bytes = 0; int tee_bytes = 0;
if(argc != 3) { if(argc != 3) {
error(1, 0, "usage: logtee /path/to/socket cookie-text"); error(1, 0, "usage: " PROGRAM_NAME " /path/to/socket cookie-text");
} }
char * socket_pathname = argv[1]; char * socket_pathname = argv[1];
char * cookie = argv[2]; char * cookie = argv[2];
@ -103,7 +105,7 @@ int main(int argc, char * argv[]) {
out_bytes = read(fds[0].fd, buf, 8192); out_bytes = read(fds[0].fd, buf, 8192);
if(out_bytes == 0) { if(out_bytes == 0) {
quitting = 1; quitting = 1;
buf = "logtee detected eof of file on stdin, exiting\n"; buf = PROGRAM_NAME " detected eof of file on stdin, exiting\n";
out_bytes = strlen(buf); out_bytes = strlen(buf);
}; };
if(is_connected()) tee_bytes = out_bytes; if(is_connected()) tee_bytes = out_bytes;