diff options
author | Juan RP <xtraeme@gmail.com> | 2019-12-28 02:42:57 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-12-28 02:42:57 +0100 |
commit | c823ae2203cb308b42e69f607cf2d9c9c41ca90e (patch) | |
tree | 4e09efa8ed818ae8113f49cfda2af24d6762cef7 /vlogger.c | |
parent | 95ad0a971eccddba4779ad153860fff3764d123a (diff) | |
parent | 06c1ad4f8b54affde57d928c9557034969c36e21 (diff) | |
download | runit-void-c823ae2203cb308b42e69f607cf2d9c9c41ca90e.tar.gz runit-void-c823ae2203cb308b42e69f607cf2d9c9c41ca90e.tar.xz runit-void-c823ae2203cb308b42e69f607cf2d9c9c41ca90e.zip |
Merge pull request #26 from Duncaen/vlogger-logger
Vlogger
Diffstat (limited to 'vlogger.c')
-rw-r--r-- | vlogger.c | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/vlogger.c b/vlogger.c index 949fb5b..64f1a2e 100644 --- a/vlogger.c +++ b/vlogger.c @@ -78,12 +78,12 @@ main(int argc, char *argv[]) { char buf[1024]; char *p, *argv0; - char *tag = "vlogger"; + char *tag = NULL; int c; int Sflag = 0; int logflags = 0; - int facility = LOG_DAEMON; - int level = LOG_INFO; + int facility = LOG_USER; + int level = LOG_NOTICE; argv0 = *argv; @@ -94,7 +94,7 @@ main(int argc, char *argv[]) *p = '\0'; if ((p = strrchr(pwd, '/')) && strncmp(p+1, "log", 3) == 0 && (*p = '\0', (p = strrchr(pwd, '/'))) && (*(p+1) != '\0')) { - tag = strdup(p+1); + tag = p+1; } } } @@ -119,9 +119,12 @@ main(int argc, char *argv[]) argc -= optind; argv += optind; + if (argc > 0) + Sflag++; + if (!Sflag && access("/etc/vlogger", X_OK) != -1) { CODE *cp; - const char *sfacility, *slevel; + const char *sfacility = "", *slevel = ""; for (cp = prioritynames; cp->c_name; cp++) { if (cp->c_val == level) slevel = cp->c_name; @@ -135,7 +138,7 @@ main(int argc, char *argv[]) exit(1); } - openlog(tag, logflags, facility); + openlog(tag ? tag : getlogin(), logflags, facility); if (argc > 0) { size_t len; |