liminix

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README | LICENSE

commit 5771108fed5581d53baf43ef9ec26371ac5b2bca
parent 9e5f2d663d9acb4c30e714a062efa4e917c1a970
Author: Daniel Barlow <dan@telent.net>
Date:   Mon, 16 Sep 2024 20:34:26 +0100

improve logtee socket connection warning

* print it less often
* to the correct stream (stdout not stderr)

Diffstat:
Mpkgs/logshipper/logtee.c | 8+++++++-
1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/pkgs/logshipper/logtee.c b/pkgs/logshipper/logtee.c @@ -14,6 +14,7 @@ int open_shipper_socket(char *pathname) { int fd; + static int fail_count = 0; struct sockaddr_un sa = { .sun_family = AF_LOCAL @@ -23,7 +24,12 @@ int open_shipper_socket(char *pathname) { fd = socket(AF_LOCAL, SOCK_STREAM, 0); if(fd >= 0) { if(connect(fd, (struct sockaddr *) &sa, sizeof sa)) { - error(0, errno, "connect socket \"%s\"", pathname); + if((fail_count % 30) == 0) + printf("logtee: cannot connect socket \"%s\": %s\n", + pathname, + strerror(errno)); + + fail_count++; close(fd); return -1; }