Add support for logger -u /tmp/foo to log to alternate socket

Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
This commit is contained in:
Joachim Nilsson
2019-10-29 10:43:14 +01:00
parent 08aa942ffb
commit ec9c92987f
3 changed files with 16 additions and 2 deletions

View File

@@ -205,9 +205,10 @@ int main(int argc, char *argv[])
int rotate = 0;
off_t size = 200 * 1024;
char *ident = NULL, *logfile = NULL;
char *sockpath = NULL;
char buf[512] = "";
while ((c = getopt(argc, argv, "?f:p:r:st:v")) != EOF) {
while ((c = getopt(argc, argv, "?f:p:r:st:u:v")) != EOF) {
switch (c) {
case 'f':
logfile = optarg;
@@ -230,6 +231,10 @@ int main(int argc, char *argv[])
ident = optarg;
break;
case 'u':
sockpath = optarg;
break;
case 'v': /* version */
fprintf(stderr, "%s\n", version_info);
return 0;
@@ -267,6 +272,10 @@ int main(int argc, char *argv[])
}
log.log_file = fileno(fp);
} else if (sockpath) {
if (access(sockpath, W_OK))
err(1, "Socket path %s", sockpath);
log.log_sockpath = sockpath;
}
openlog_r(ident, log_opts, facility, &log);